# AssertionError: Expected 'mock_method' to be called once. Called 2 times.

- **ID:** `python/pytest-mock-not-reset-between-tests`
- **Domain:** python
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A mock object was not reset between tests, so call counts accumulated from previous tests. This happens when mocks are defined at module level or shared via class attributes.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   @pytest.fixture
def mock_service():
    return MagicMock()

def test_one(mock_service):
    mock_service.method()
    mock_service.method.assert_called_once()
   ```
2. **** (93% success)
   ```
   def test_one(mocker):
    mock = mocker.patch('module.func')
    mock()
    mock.assert_called_once()
   ```

## Dead Ends

- **** — If a test fails before reaching the reset line, the mock remains dirty for the next test. Also error-prone to maintain. (75% fail)
- **** — This changes the assertion but does not fix the accumulated call count. The assertion will still fail. (85% fail)
