This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author 153957
Recipients 153957, docs@python
Date 2016-12-08.21:48:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1481233700.68.0.637550951007.issue28911@psf.upfronthosting.co.za>
In-reply-to
Content
The name assert_called_once_with and the current method documentation can be interpreted to mean that it asserts that there is precisely one call matching the given signature, regardless of the total number of calls. However, the method first checks that there is precisely one call, and then checks if that call has a signature matching the provided signature.

Additionally, the assert_any_call method documentation references assert_called_once_with in a way that enforces the possible misinterpretation: "… assert_called_with and assert_called_once_with that only pass if the call is the most recent one". This may lead to the interpretation that there must be only one call with the given signature and  that it must be the most recent one, it must in fact be the only one.

In the mock examples documentation there is an important sentence that clarifies the actual functionality: "you can use the assert_called_once_with method that also asserts that the call_count is one".

The example provided in the method documentation also does not satisfactorily address the ambiguity, because it only calls the mock with one call signature. By changing the call signature of the second call (and in the assert) in the example the purpose of the method becomes clearer.
History
Date User Action Args
2016-12-08 21:48:20153957setrecipients: + 153957, docs@python
2016-12-08 21:48:20153957setmessageid: <1481233700.68.0.637550951007.issue28911@psf.upfronthosting.co.za>
2016-12-08 21:48:20153957linkissue28911 messages
2016-12-08 21:48:20153957create