diff options
author | Abraham Toriz Cruz <awonderfulcode@gmail.com> | 2019-09-17 11:16:08 (GMT) |
---|---|---|
committer | Pablo Galindo <Pablogsal@gmail.com> | 2019-09-17 11:16:08 (GMT) |
commit | 5f5f11faf9de0d8dcbe1a8a4eb35d2a4232d6eaa (patch) | |
tree | 18cdf4ee14ec18b596aa1ea5f6fb4ad60bccc508 /Lib/unittest/mock.py | |
parent | 219fb9d65ef7e5363eccc9dde0988bb085db1c86 (diff) | |
download | cpython-5f5f11faf9de0d8dcbe1a8a4eb35d2a4232d6eaa.zip cpython-5f5f11faf9de0d8dcbe1a8a4eb35d2a4232d6eaa.tar.gz cpython-5f5f11faf9de0d8dcbe1a8a4eb35d2a4232d6eaa.tar.bz2 |
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').
Diffstat (limited to 'Lib/unittest/mock.py')
-rw-r--r-- | Lib/unittest/mock.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py index 74d32af..4cf8e60 100644 --- a/Lib/unittest/mock.py +++ b/Lib/unittest/mock.py @@ -868,7 +868,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): |