Python: self.assertEqual(a, b, msg) --> I want diff AND msg -
if call this, see nice diff:
self.assertequal(a, b)
if call this, see msg only:
self.assertequal(a, b, msg)
is there easy way show diff , msg?
implementing assertequal()
myself work, ask myself if best way.
plattform: python2.7 , pytest 2.6.2.
if set longmessage
attribute true
, see both message.
example:
class testfoo(unittest.testcase): longmessage = true # <-- def test_foo(self): self.assertequal(1+2, 2, 'custom message')
output:
f ====================================================================== fail: test_foo (__main__.testfoo) ---------------------------------------------------------------------- traceback (most recent call last): file "t.py", line 6, in test_foo self.assertequal(1+2, 2, 'custom message') assertionerror: 3 != 2 : custom message ---------------------------------------------------------------------- ran 1 test in 0.000s
Comments
Post a Comment