[issue7709] the msg parameters of PyUnit assertions, such as assertEqual, should not obscure the automated diagnostics, such as '%s != %s'

Phlip report at bugs.python.org
Fri Jan 15 19:55:18 CET 2010


New submission from Phlip <phlip2005 at gmail.com>:

The various assertions are not DRY when they force you to repeat any automatic diagnostic in a message string, if you provide it.

Here's an example:

    def assertEqual(self, first, second, msg=None):
         self.assert_((first == second), msg or '%s != %s' % (first, second))

I think it should work like this:
 
     def assertEqual(self, first, second, msg=''):
         self.assert_((first == second),
 		(msg + ('\n%s != %s' % (first, second))).strip())
 
That way, if you provide a message (such as a message describing the semantic _meaning_ why "41" should not equal "42"), the assertion does not throw away the automatically generated "41 != 42".

In the current system, to correctly reflect the 41 and 42, you must add them to the msg body. This is redundant with the assertions' primary behaviors...

----------
components: Tests
messages: 97833
nosy: Phlip
severity: normal
status: open
title: the msg parameters of PyUnit assertions, such as assertEqual, should not obscure the automated diagnostics, such as '%s != %s'
type: feature request
versions: Python 3.2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7709>
_______________________________________


More information about the Python-bugs-list mailing list