Message285433
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? |
|
Date |
User |
Action |
Args |
2017-01-13 18:17:54 | lisroach | set | recipients:
+ lisroach, vstinner, michael.foord, docs@python, berker.peksag |
2017-01-13 18:17:54 | lisroach | set | messageid: <1484331474.46.0.558237777572.issue28911@psf.upfronthosting.co.za> |
2017-01-13 18:17:54 | lisroach | link | issue28911 messages |
2017-01-13 18:17:54 | lisroach | create | |
|