PyDocs

Nav

Development Tools

Mock.assert_has_calls

  • Mock.assert_has_calls(calls, any_order=False)
Assert the mock has been called with the specified calls.
The `mock_calls` list is checked for the calls.

If `any_order` is False (the default) then the calls must be
sequential. There can be extra calls before or after the
specified calls.

If `any_order` is True then the calls can be in any order, but
they must all appear in `mock_calls`.
1 Example
>>> mock = Mock(return_value=None)
>>> mock(1)
>>> mock(2)
>>> mock(3)
>>> mock(4)
>>> calls = [call(2), call(3)]
>>> mock.assert_has_calls(calls)
>>> calls = [call(4), call(2), call(3)]
>>> mock.assert_has_calls(calls, any_order=True)
from the Python docs
See Also
No see-alsos for unittest.mock/Mock.assert_has_calls
0 Notes
No notes for Mock.assert_has_calls