python
runtime_error
ai_generated
true
AssertionError: Expected 'foo' to be called with (1,) but was called with (2,)
ID: python/unittest-mock-side-effect-assertion-error
80%Fix Rate
85%Confidence
0Evidence
2025-08-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.x | active | — | — | — |
Root Cause
The mock's call arguments don't match the expected arguments, often due to incorrect input or mock configuration.
generic中文
mock 的调用参数与预期参数不匹配,通常是由于输入错误或 mock 配置错误。
Workarounds
-
90% success
print(mock.call_args) assert mock.call_args == call(1,)
-
85% success
mock.assert_any_call(1)
Dead Ends
Common approaches that don't work:
-
80% fail
This hides the real bug in the code.
-
90% fail
It still fails if arguments don't match.