Improve error message when mock.assert_has_calls fails (GH-8205)

This makes the assertion error message more useful, aiding debugging.

Thanks @davidair!
This commit is contained in:
davidair 2018-08-17 15:09:58 -04:00 committed by Gregory P. Smith
parent a2510732da
commit 2b32da2fea
2 changed files with 4 additions and 1 deletions

View File

@ -862,7 +862,9 @@ class NonCallableMock(Base):
not_found.append(kall)
if not_found:
raise AssertionError(
'%r not all found in call list' % (tuple(not_found),)
'%r does not contain all of %r in its call list, '
'found %r instead' % (self._mock_name or 'mock',
tuple(not_found), all_calls)
) from cause

View File

@ -0,0 +1 @@
Improved an error message when mock assert_has_calls fails.