mock_func called twice with arguments (1, 2) and (3, 4), which assertion correctly verifies these calls in order?from unittest.mock import Mock, call mock_func = Mock() mock_func(1, 2) mock_func(3, 4)
assert_has_calls with any_order=False to check call order.assert_has_calls with any_order=False checks that the calls happened in the exact order given. assert_called_with only checks the last call. assert_called_once_with expects exactly one call, so it fails if called multiple times. assert_any_call checks calls but ignores order.
mock_func.call_count after running this code?from unittest.mock import Mock mock_func = Mock() mock_func('a') mock_func('b') mock_func('c') print(mock_func.call_count)
The call_count attribute counts how many times the mock was called. Here, it is called three times, so the value is 3.
from unittest.mock import Mock mock_func = Mock() mock_func(5, 6) mock_func.assert_called_with(6, 5)
assert_called_with checks that the last call to the mock matches the arguments exactly in order and value. Here, the call was (5, 6) but the assertion checks (6, 5), so it fails.
mock_func was never called?assert_not_called() checks that the mock was never called. assert_called_once() expects exactly one call. assert_any_call() checks if called with specific args. assert_called() checks if called at least once.
mock_func(a=1, b=2). Which assertion will fail to verify this call correctly?from unittest.mock import Mock mock_func = Mock() mock_func(a=1, b=2)
When a mock is called with keyword arguments, assert_called_with must use the same keywords. Option B uses positional arguments which do not match the call, so it fails. Options A, C, and D correctly match keyword arguments regardless of order.