Test Overview
This test checks if a mocked function is called with the expected arguments. It verifies that the function was called exactly once with the correct parameters.
This test checks if a mocked function is called with the expected arguments. It verifies that the function was called exactly once with the correct parameters.
from unittest.mock import Mock import pytest def test_mock_call(): mock_func = Mock() # Call the mock function with specific arguments mock_func('hello', key='value') # Assert the mock was called once with the expected arguments mock_func.assert_called_once_with('hello', key='value')
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Create a mock function object | mock_func is a Mock object with no calls recorded | - | PASS |
| 2 | Call mock_func with arguments ('hello', key='value') | mock_func records one call with arguments ('hello', key='value') | - | PASS |
| 3 | Assert mock_func was called once with ('hello', key='value') | mock_func call history matches expected arguments | mock_func.assert_called_once_with('hello', key='value') verifies call count and arguments | PASS |