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

Susan Su report at bugs.python.org
Wed Feb 13 02:43:39 EST 2019


Susan Su <susansu.software at gmail.com> added the comment:

After taking a look at the assert_called_with function, I noticed that the formatting is inconsistent for the following case:
from unittest import mock

m = mock.Mock()
a = [1, 2, 3, 4]
m.assert_called_with(*a)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/vagrant/cpython/Lib/unittest/mock.py", line 817, in assert_called_with
    raise AssertionError('Expected call: %s\nNot called' % (expected,))
AssertionError: Expected call: mock(1, 2, 3)
Not called


If you believe it would be appropriate, I would like to change the format of the code above to the following:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/vagrant/cpython/Lib/unittest/mock.py", line 817, in assert_called_with
    raise AssertionError(
AssertionError: expected call not found.
Expected: mock(1, 2, 3, 4)
Not called

This way, we would create consistency in our output.

----------
nosy: +suhearsawho

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


More information about the Python-bugs-list mailing list