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

bpo-35946: Improve assert_called_with documentation #11796

Open
wants to merge 2 commits into
base: master
from

Conversation

Projects
None yet
5 participants
@remilapeyre
Copy link
Contributor

remilapeyre commented Feb 8, 2019

No news entry is needed for this change.

https://bugs.python.org/issue35946

@tirkarthi
Copy link
Contributor

tirkarthi left a comment

LGTM. docstring has a note that it's for the last call so docs can be clarified too.

$ pydoc3.7 unittest.mock.Mock.assert_called_with | cat
Help on function assert_called_with in unittest.mock.Mock:

unittest.mock.Mock.assert_called_with = assert_called_with(_mock_self, *args, **kwargs)
    assert that the mock was called with the specified arguments.

    Raises an AssertionError if the args and keyword args passed in are
    different to the last call to the mock.

Thanks!

@Mariatta
Copy link
Member

Mariatta left a comment

This sounds clearer. Thanks!

@Mariatta

This comment has been minimized.

Copy link
Member

Mariatta commented Feb 9, 2019

Good call, @tirkarthi. Yeah let's update the docstring too while we're at it.

@remilapeyre

This comment has been minimized.

Copy link
Contributor Author

remilapeyre commented Feb 9, 2019

@tirkarthi I chenged it, thanks!

@@ -807,7 +807,8 @@ def assert_called_once(_mock_self):
raise AssertionError(msg)

def assert_called_with(_mock_self, *args, **kwargs):
"""assert that the mock was called with the specified arguments.
"""assert that the last call to the mock was made with the specified

This comment has been minimized.

@Mariatta

Mariatta Feb 9, 2019

Member

The docstring's summary line should only be in one line. Any way this can be made more concise and less than 80 characters? 🤔

This comment has been minimized.

@remilapeyre

remilapeyre Feb 9, 2019

Author Contributor

Hi @Mariatta, I was not aware of this rule, thanks. What do you think of:

assert that the last call was made with the specified arguments.

While the other docstrings need the mock to be grammatically correct, it seems to me that this one doesn't and the context here is sufficient?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment