Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs for mock.call #88850

Open
guettli mannequin opened this issue Jul 20, 2021 · 3 comments
Open

Docs for mock.call #88850

guettli mannequin opened this issue Jul 20, 2021 · 3 comments
Labels
3.9 only security fixes docs Documentation in the Doc dir

Comments

@guettli
Copy link
Mannequin

guettli mannequin commented Jul 20, 2021

BPO 44684
Nosy @tirkarthi

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2021-07-20.14:38:46.011>
labels = ['3.9', 'docs']
title = 'Docs for mock.call'
updated_at = <Date 2021-07-20.16:10:03.586>
user = 'https://bugs.python.org/guettli'

bugs.python.org fields:

activity = <Date 2021-07-20.16:10:03.586>
actor = 'xtreak'
assignee = 'docs@python'
closed = False
closed_date = None
closer = None
components = ['Documentation']
creation = <Date 2021-07-20.14:38:46.011>
creator = 'guettli'
dependencies = []
files = []
hgrepos = []
issue_num = 44684
keywords = []
message_count = 2.0
messages = ['397874', '397887']
nosy_count = 3.0
nosy_names = ['guettli', 'docs@python', 'xtreak']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = None
url = 'https://bugs.python.org/issue44684'
versions = ['Python 3.9']

@guettli
Copy link
Mannequin Author

guettli mannequin commented Jul 20, 2021

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.

@guettli guettli mannequin added the 3.9 only security fixes label Jul 20, 2021
@guettli guettli mannequin assigned docspython Jul 20, 2021
@guettli guettli mannequin added 3.9 only security fixes docs Documentation in the Doc dir labels Jul 20, 2021
@guettli guettli mannequin assigned docspython Jul 20, 2021
@guettli guettli mannequin added the docs Documentation in the Doc dir label Jul 20, 2021
@tirkarthi
Copy link
Member

A call object is either a tuple of (positional args, keyword args) or (name, positional args, keyword args) depending on how it was constructed

#11807 added support for args and kwargs from python 3.9. So I guess you want to do call_object.kwargs["foo"] == "bar"

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
@slateny
Copy link
Contributor

slateny commented Apr 16, 2022

Scrolling down briefly from unittest.mock.call the page does give an example with args and kwargs

...
>>> m(1, 2, 3, arg='one', arg2='two')
>>> kall = m.call_args
>>> kall.args
(1, 2, 3)
...

Would that be good enough as an example or better to put it directly under call()?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.9 only security fixes docs Documentation in the Doc dir
Projects
Status: No status
Development

No branches or pull requests

2 participants