[issue28911] Clarify the behaviour of assert_called_once_with
Changes by Arne de Laat <adel...@leukeleu.nl>: -- pull_requests: +222 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28911> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28911] Clarify the behaviour of assert_called_once_with
Changes by Arne de Laat <adel...@leukeleu.nl>: -- pull_requests: +220 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28911> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28911] Clarify the behaviour of assert_called_once_with
Changes by Arne de Laat <adel...@leukeleu.nl>: -- pull_requests: +219 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28911> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28911] Clarify the behaviour of assert_called_once_with
Arne de Laat added the comment: *ping* Is this patch acceptable as is? Perhaps a new issue can be made for a method to check at most one call with a specific signature i.e. `assert_one_call_with`. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28911> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28911] Clarify the behaviour of assert_called_once_with
Arne de Laat added the comment: Unfortunately there cant be commas in the method name, that would clarify the name. It should be read as 'assert called once, with ...' not 'assert called once with ...'. I have often used the method to test something was called only once, and with the specified arguments. It seems that it is more difficult (i.e. no single method) to check if only one call was made with the specified arguments (allowing for more calls with other arguments), perhaps that could be added. Something like 'assert_once_called_with' or 'assert_one_call_with'. -- nosy: +153957 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28911> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28911] Clarify the behaviour of assert_called_once_with
New submission from Arne de Laat: 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. -- assignee: docs@python components: Documentation, Tests files: assert_once_with_doc.patch keywords: patch messages: 282740 nosy: 153957, docs@python priority: normal severity: normal status: open title: Clarify the behaviour of assert_called_once_with type: enhancement versions: Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7 Added file: http://bugs.python.org/file45803/assert_once_with_doc.patch ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28911> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com