python
data_error
ai_generated
true
Failed: [pytest] empty parameter set in 'test_parse' at tests/test_parse.py:12
ID: python/pytest-parametrize-empty-list
80%Fix Rate
88%Confidence
0Evidence
2024-07-19First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 7.x | active | — | — | — |
| 8.x | active | — | — | — |
Root Cause
pytest.mark.parametrize received an empty list for argvalues, so pytest reports an empty parameter set and fails the test by default (controlled by empty_parameter_set_mark).
generic中文
pytest.mark.parametrize 收到空列表作为 argvalues,pytest 报告空参数集并默认使测试失败(由 empty_parameter_set_mark 控制)。
Workarounds
-
90% success
# pytest.ini [pytest] empty_parameter_set_mark = skip
-
88% success
CASES = load_cases() or [pytest.param(None, marks=pytest.mark.skip('no cases'))] @pytest.mark.parametrize('case', CASES) def test_parse(case): ...
Dead Ends
Common approaches that don't work:
-
70% fail
Loses parameterization entirely; the test now runs once with undefined arguments and fails differently.
-
65% fail
Hides the fact that the data source is empty, which is often the actual bug worth surfacing.