Complete the code to assert the mock was called exactly once.
mock_function.[1]()The assert_called_once() method checks that the mock was called exactly one time.
Complete the code to assert the mock was called with specific arguments.
mock_function.[1](42, 'test')
The assert_called_once_with() method asserts the mock was called exactly once with the given arguments.
Fix the error in the assertion to check the mock was never called.
mock_function.[1]()The assert_not_called() method asserts the mock was never called.
Fill both blanks to assert the mock was called twice and with specific arguments on the second call.
assert mock_function.call_count == [1] mock_function.[2](100, key='value')
First, we check the call count equals 2. Then, assert_any_call() checks if the mock was called with the given arguments at least once (e.g., the second call).
Fill all three blanks to assert the mock was called with specific arguments and check the first call's arguments.
mock_function.[1](5, 10) assert mock_function.call_args == [2] assert mock_function.call_args_list[0] == [3]
assert_called_once_with asserts the mock was called once with the arguments (5, 10). call_args holds the last call's Call ((5, 10), {}). call_args_list[0] holds the first call's Call ((5, 10), {}).