Message331849
Currently, assert_called_with has expected calls list in the same line with AssertionError that causes the visualizing the difference to be hard. It will be great if Expected call occurs on the next line so that the diff is improved. The change has to be made at https://github.com/python/cpython/blob/f8e9bd568adf85c1e4aea1dda542a96b027797e2/Lib/unittest/mock.py#L749 .
from unittest import mock
m = mock.Mock()
m(1, 2)
m.assert_called_with(2, 3)
Current output :
Traceback (most recent call last):
File "/tmp/bar.py", line 5, in <module>
m.assert_called_with(2, 3)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/unittest/mock.py", line 820, in assert_called_with
raise AssertionError(_error_message()) from cause
AssertionError: Expected call: mock(2, 3)
Actual call: mock(1, 2)
Proposed output :
Traceback (most recent call last):
File "/tmp/bar.py", line 5, in <module>
m.assert_called_with(2, 3)
File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/unittest/mock.py", line 827, in assert_called_with
raise AssertionError(_error_message()) from cause
AssertionError:
Expected call: mock(2, 3)
Actual call: mock(1, 2)
Some more alignment with the call list starting in the same column
AssertionError:
Expected call: mock(2, 3)
Actual call: mock(1, 2)
Originally reported in the GitHub repo at https://github.com/testing-cabal/mock/issues/424 . PR for this was closed since GitHub is used only for backporting (https://github.com/testing-cabal/mock/pull/425). I thought to report it here for discussion. Currently call list output is as per proposed output.
AssertionError: Calls not found.
Expected: [call(1, 2, 3)]
Actual: [call(1, 2)]. |
|
Date |
User |
Action |
Args |
2018-12-14 18:45:46 | xtreak | set | recipients:
+ xtreak, cjw296, michael.foord, mariocj89 |
2018-12-14 18:45:46 | xtreak | set | messageid: <1544813146.35.0.788709270274.issue35500@psf.upfronthosting.co.za> |
2018-12-14 18:45:46 | xtreak | link | issue35500 messages |
2018-12-14 18:45:46 | xtreak | create | |
|