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

pytest introspection with assert_called_once_with() #154

Closed
The-Compiler opened this issue Sep 16, 2019 · 2 comments · Fixed by #162
Closed

pytest introspection with assert_called_once_with() #154

The-Compiler opened this issue Sep 16, 2019 · 2 comments · Fixed by #162

Comments

@The-Compiler
Copy link
Member

When a mock is called multiple times (with the right arguments, at some point) but only one call is expected:

def test_foo(mocker):
    mock = mocker.Mock()
    mock('foo')
    mock('test')
    mock.assert_called_once_with('test')

the output is:

>       mock.assert_called_once_with('test')
E       AssertionError: Expected 'mock' to be called once. Called 2 times.
E       
E       pytest introspection follows:

test_x.py:5: AssertionError

which is kind of confusing.

@twmr
Copy link

twmr commented Sep 17, 2019

By confusing you mean that there is no output after "pytest introspection follows", right?

@The-Compiler
Copy link
Member Author

Yep! Ideally, there would be a pytest introspection of all calls there (something like "expected: [mock.call('test')], got [mock.call('foo'), mock.call('test')]" or so) - but at least, there shouldn't be a "pytest introspection follows:" if nothing actually follows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants