[Pyunit-interest] why assertEqual's msg parameter is designed to obscure the '%s != %s' diagnostic?
Brought to you by:
purcell
From: Phlip <phl...@gm...> - 2010-01-13 20:09:26
|
PyUnit: (Long time first time!) 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 "41" and "42". Reflecting the source expressions passed in first and second is left as an exercise for the reader. C-: -- Phlip http://zeekland.zeroplayer.com/Uncle_Wiggilys_Travels/1 |