PyDocs

Nav

Development Tools

Mock.assert_called_once_with

  • Mock.assert_called_once_with(*args, **kwargs)
Assert that the mock was called exactly once and that call was
with the specified arguments.
1 Example
>>> mock = Mock(return_value=None)
>>> mock('foo', bar='baz')
>>> mock.assert_called_once_with('foo', bar='baz')
>>> mock('other', bar='values')
>>> mock.assert_called_once_with('other', bar='values')
Traceback (most recent call last):
  ...
AssertionError: Expected 'mock' to be called once. Called 2 times.
Calls: [call('foo', bar='baz'), call('other', bar='values')].
from the Python docs
See Also
No see-alsos for unittest.mock/Mock.assert_called_once_with
0 Notes
No notes for Mock.assert_called_once_with