unittest.mock.Mock.assert_called_once_with()

assert_called_once_with(*args, **kwargs)

Assert that the mock was called exactly once and with the specified arguments.

>>> mock = Mock(return_value=None)
>>> mock('foo', bar='baz')
>>> mock.assert_called_once_with('foo', bar='baz')
>>> mock('foo', bar='baz')
>>> mock.assert_called_once_with('foo', bar='baz')
Traceback (most recent call last):
  ...
AssertionError: Expected 'mock' to be called once. Called 2 times.
doc_python
2016-10-07 17:46:08
Comments
Leave a Comment

Please login to continue.