# AssertionError: Expected 'mock.method' to have been called once. Called 2 times.

- **ID:** `python/unittest-mock-assert-call-order`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

使用 assert_called_once 但 mock 方法被多次调用，可能由于代码逻辑或测试重复执行。

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.9 | active | — | — |
| 3.10 | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   检查最后一次调用参数，`mock.method.assert_called_with(参数)`。
   ```
2. **** (95% success)
   ```
   `assert mock.method.call_count == 1` 更精确。
   ```

## Dead Ends

- **** — 可能改变被测代码行为。 (50% fail)
- **** — 不验证调用次数，可能掩盖问题。 (60% fail)
