[New-bugs-announce] [issue28054] Diff for visually comparing actual with expected in mock.assert_called_with.

Eli Rose report at bugs.python.org
Fri Sep 9 18:44:33 EDT 2016


New submission from Eli Rose:

When I call unittest.TestCase.assertEqual(a, b) on e.g. two unequal dictionaries, I get a nice diff pointing me to the differences.

>>> class A(unittest.TestCase):
...     def test_foo(self):
...         self.assertEqual(dict(foo='bar', zab='zar'), dict(foo='bar', zab='zab'))
>>> unittest.main()
======================================================================
FAIL: test_foo (__main__.A)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "<stdin>", line 3, in test_foo
AssertionError: {'foo': 'bar', 'zab': 'zar'} != {'foo': 'bar', 'zab': 'zab'}
- {'foo': 'bar', 'zab': 'zar'}
?                          ^

+ {'foo': 'bar', 'zab': 'zab'}
?                          ^


----------------------------------------------------------------------
Ran 1 test in 0.001s

FAILED (failures=1)

But when unittest.mock.Mock.assert_called_with fails, I don't get this nice diff output.

This would be very helpful in my present case (asserting that a function with many keyword arguments is called correctly).

----------
components: Tests
messages: 275481
nosy: Eli Rose
priority: normal
severity: normal
status: open
title: Diff for visually comparing actual with expected in mock.assert_called_with.
type: enhancement
versions: Python 2.7, Python 3.3

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


More information about the New-bugs-announce mailing list