Mock has a helpful assert_called_with()
method. However, as far as I understand this only checks the last call to a method.
If I have code that calls the mocked method 3 times successively, each time with different parameters, how can I assert these 3 calls with their specific parameters?
Python – Asserting successive calls to a mock method
mockingpython
Best Answer
assert_has_calls
is another approach to this problem.From the docs:
Example:
Source: https://docs.python.org/3/library/unittest.mock.html#unittest.mock.Mock.assert_has_calls