Lisa Roach added the comment:
It took me a little while to wrap my brain around this, but you are definitely
right that the documentation is not sufficient, your changes are an
improvement.
My wonder is, should we change the documentation or be looking at the code
itself? I have always interpreted the method as asserting that only one call
was made with the matching signature. If I want to test for call count I can
just assert mock.call_count == 1.
The code could instead look like this:
def assert_called_once_with(_mock_self, *args, **kwargs):
self = _mock_self
if not self.mock_calls.count(call(*args, **kwargs)) == 1:
msg = ("Expected '%s' to be called once with %r %r. Called %s times."
% (self._mock_name or 'mock', args, kwargs,
self.mock_calls.count(call(*args, **kwargs))))
raise AssertionError(msg)
Then again, if users have been using this to assert that the call_count is one
(which is likely since it is in the examples documentation), this change would
break backwards functionality.
Thoughts?
----------
nosy: +lisroach
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue28911>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com