[issue35500] Align expected and actual calls on mock.assert_called_with error message

Mario Corchero report at bugs.python.org
Sat Dec 15 17:27:29 EST 2018


Mario Corchero <mariocj89 at gmail.com> added the comment:

Makes sense!

I'd not align them though but that might be my view as I generally don't like aligning text like that.

Also if you feel that the exceptions read "weird" with the first sentence is empty, an option might be to say the calls don't match, to make it symmetric with the assert_calls message. Example:


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 not found.
Expected call: mock(2, 3)
Actual call: mock(1, 2)

This way all error reports give you the issue in the first line of the message and further details in the next lines.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35500>
_______________________________________


More information about the Python-bugs-list mailing list