# 断言错误：期望 mock 被调用一次。实际调用 0 次。

- **ID:** `python/unittest-mock-return-value-not-asserted`
- **领域:** python
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

mock 对象的调用次数与预期不符，通常是由于补丁目标错误或逻辑错误。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |

## 解决方案

1. **** (90% 成功率)
   ```
   with patch('module.function') as mock_func:
    call_code()
    mock_func.assert_called_once()
   ```
2. **** (85% 成功率)
   ```
   mock_func.assert_any_call(arg1, arg2)
   ```

## 无效尝试

- **** — This masks the real problem of why the code isn't calling the mock. (70% 失败率)
- **** — The test becomes ineffective. (90% 失败率)
