python
runtime_error
ai_generated
true
AssertionError: expected call not found. Expected: mock(1) Actual: mock(2)
ID: python/unittest-assertcount-equal-error
80%Fix Rate
85%Confidence
0Evidence
2024-09-20First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.12 | active | — | — | — |
Root Cause
使用 assert_called_with 检查 mock 调用时,参数不匹配
generic中文
使用 assert_called_with 检查 mock 调用时,参数不匹配
Workarounds
-
90% success
print(mock.call_args_list) 然后修正预期
-
80% success
mock.assert_any_call(1)
Dead Ends
Common approaches that don't work:
-
60% fail
只检查调用次数,不检查参数
-
30% fail
可能不符合测试意图