New submission from Phlip <phlip2...@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 <rep...@bugs.python.org>
<http://bugs.python.org/issue7709>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to