classification
Title: Docs for mock.call
Type: Stage:
Components: Documentation Versions: Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, guettli, xtreak
Priority: normal Keywords:

Created on 2021-07-20 14:38 by guettli, last changed 2021-07-20 16:10 by xtreak.

Messages (2)
msg397874 - (view) Author: Thomas Guettler (guettli) * Date: 2021-07-20 14:38
The docs for `mock.call` could get improved:

https://docs.python.org/3/library/unittest.mock.html#call

Up to now it is not clear how to access individual members of the call.

Example: I want to check if the call used the kwarg "foo" with the value of "bar".

Usually you don't need this, since you check for the whole call (all args and all kwargs).

But sometimes you jus twant to check for a single arg/kwarg.

Then it would be nice to have more detailed docs for the class "call".

BTW: Why has this class a lower-case name? Looks a bit strange.
msg397887 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2021-07-20 16:10
> A call object is either a tuple of (positional args, keyword args) or (name, positional args, keyword args) depending on how it was constructed

https://github.com/python/cpython/pull/11807 added support for args and kwargs from python 3.9. So I guess you want to do call_object.kwargs["foo"] == "bar"
History
Date User Action Args
2021-07-20 16:10:03xtreaksetnosy: + xtreak
messages: + msg397887
2021-07-20 14:38:46guettlicreate