mirror of
https://github.com/python/cpython.git
synced 2025-08-30 05:35:08 +00:00
bpo-37828: Fix default mock_name in unittest.mock.assert_called error (GH-16166)
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').
(cherry picked from commit 5f5f11faf9
)
Co-authored-by: Abraham Toriz Cruz <awonderfulcode@gmail.com>
This commit is contained in:
parent
728bea60e5
commit
f668d2b775
3 changed files with 11 additions and 1 deletions
|
@ -873,7 +873,7 @@ class NonCallableMock(Base):
|
|||
"""
|
||||
if self.call_count == 0:
|
||||
msg = ("Expected '%s' to have been called." %
|
||||
self._mock_name or 'mock')
|
||||
(self._mock_name or 'mock'))
|
||||
raise AssertionError(msg)
|
||||
|
||||
def assert_called_once(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue