python type_error ai_generated true

ValueError: got 3 arguments for 2 parameters: ('a', 'b')

ID: python/pytest-mark-parametrize-argument-count

Also available as: JSON · Markdown · 中文
80%Fix Rate
90%Confidence
0Evidence
2024-12-02First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
7.4.0 active

Root Cause

在 parametrize 中提供的参数数量与测试函数参数数量不匹配。

generic

中文

在 parametrize 中提供的参数数量与测试函数参数数量不匹配。

Workarounds

  1. 100% success
    确保参数数量一致,如 `@pytest.mark.parametrize('a,b', [(1,2), (3,4)])`。
  2. 90% success
    `@pytest.mark.parametrize('a,b', [{'a':1, 'b':2}])` 更清晰。

Dead Ends

Common approaches that don't work:

  1. 50% fail

    可能破坏测试逻辑,且需要同步修改 parametrize。

  2. 100% fail

    pytest 不会忽略,直接报错。