This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author xtreak
Recipients cjw296, mariocj89, michael.foord, xtreak
Date 2019-08-12.07:12:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1565593953.82.0.916439327482.issue37828@roundup.psfhosted.org>
In-reply-to
Content
In the format string for assert_called the evaluation order is incorrect and hence for mock's without name 'None' is printed whereas it should be 'mock' like for other messages. The error message is ("Expected '%s' to have been called." % self._mock_name or 'mock') . Here self._mock_name which is None is applied to form the string and then used with the string 'mock' in or combination. The fix would be to have the evaluation order correct like other error messages. Marking this as newcomer-friendly. Please leave this to new contributors as their 1st PR.

./python.exe
Python 3.9.0a0 (heads/master:f03b4c8a48, Aug 12 2019, 10:04:10)
[Clang 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from unittest.mock import Mock
>>> m = Mock()
>>> m.assert_called_once()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/unittest/mock.py", line 854, in assert_called_once
    raise AssertionError(msg)
AssertionError: Expected 'mock' to have been called once. Called 0 times.
>>> m.assert_called()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/unittest/mock.py", line 844, in assert_called
    raise AssertionError(msg)
AssertionError: Expected 'None' to have been called.


Thanks
History
Date User Action Args
2019-08-12 07:12:33xtreaksetrecipients: + xtreak, cjw296, michael.foord, mariocj89
2019-08-12 07:12:33xtreaksetmessageid: <1565593953.82.0.916439327482.issue37828@roundup.psfhosted.org>
2019-08-12 07:12:33xtreaklinkissue37828 messages
2019-08-12 07:12:33xtreakcreate