python
type_error
ai_generated
true
ValueError: got 3 arguments for 2 parameters: ('a', 'b')
ID: python/pytest-mark-parametrize-argument-count
80%Fix Rate
90%Confidence
0Evidence
2024-12-02First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 7.4.0 | active | — | — | — |
Root Cause
在 parametrize 中提供的参数数量与测试函数参数数量不匹配。
generic中文
在 parametrize 中提供的参数数量与测试函数参数数量不匹配。
Workarounds
-
100% success
确保参数数量一致,如 `@pytest.mark.parametrize('a,b', [(1,2), (3,4)])`。 -
90% success
`@pytest.mark.parametrize('a,b', [{'a':1, 'b':2}])` 更清晰。
Dead Ends
Common approaches that don't work:
-
50% fail
可能破坏测试逻辑,且需要同步修改 parametrize。
-
100% fail
pytest 不会忽略,直接报错。