diff options
author | wookie184 <wookie1840@gmail.com> | 2024-01-04 19:11:34 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-04 19:11:34 (GMT) |
commit | 1600d78e2d090319930c6538b496ffcca120a696 (patch) | |
tree | 2c3b626e673d9fc2ccd95df497d792a0241663fe /Lib/unittest | |
parent | 1ae7ceba29771baf8f2e8d2d4c50a0355cb6b5c8 (diff) | |
download | cpython-1600d78e2d090319930c6538b496ffcca120a696.zip cpython-1600d78e2d090319930c6538b496ffcca120a696.tar.gz cpython-1600d78e2d090319930c6538b496ffcca120a696.tar.bz2 |
gh-113569: Display calls in Mock.assert_has_calls failure when empty (GH-113573)
Diffstat (limited to 'Lib/unittest')
-rw-r--r-- | Lib/unittest/mock.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py index 2adb3d7..93f4d97 100644 --- a/Lib/unittest/mock.py +++ b/Lib/unittest/mock.py @@ -1010,8 +1010,8 @@ class NonCallableMock(Base): for e in expected]) raise AssertionError( f'{problem}\n' - f'Expected: {_CallList(calls)}' - f'{self._calls_repr(prefix=" Actual").rstrip(".")}' + f'Expected: {_CallList(calls)}\n' + f' Actual: {safe_repr(self.mock_calls)}' ) from cause return @@ -1085,7 +1085,7 @@ class NonCallableMock(Base): return klass(**kw) - def _calls_repr(self, prefix="Calls"): + def _calls_repr(self): """Renders self.mock_calls as a string. Example: "\nCalls: [call(1), call(2)]." @@ -1095,7 +1095,7 @@ class NonCallableMock(Base): """ if not self.mock_calls: return "" - return f"\n{prefix}: {safe_repr(self.mock_calls)}." + return f"\nCalls: {safe_repr(self.mock_calls)}." # Denylist for forbidden attribute names in safe mode |