{"id":"5de5e6b87c226eb8","repo":"pytest-dev/pytest","slug":"empty-parameter-set-in-func-name-at-line","errorCode":null,"errorMessage":"Empty parameter set in '{func.__name__}' at line {lineno + 1}","messagePattern":"Empty parameter set in '(.+?)' at line (.+?)","errorType":"exception","errorClass":"CollectError","httpStatus":null,"severity":"error","filePath":"src/_pytest/mark/structures.py","lineNumber":76,"sourceCode":"\n\ndef get_empty_parameterset_mark(\n    config: Config, argnames: Sequence[str], func\n) -> MarkDecorator:\n    from ..nodes import Collector\n\n    argslisting = \", \".join(argnames)\n\n    _fs, lineno = getfslineno(func)\n    reason = f\"got empty parameter set for ({argslisting})\"\n    requested_mark: _EmptyParameterSetMark = config.getini(EMPTY_PARAMETERSET_OPTION)\n    match requested_mark:\n        case \"skip\":\n            return MARK_GEN.skip(reason=reason)\n        case \"xfail\":\n            return MARK_GEN.xfail(reason=reason, run=False)\n        case \"fail_at_collect\":\n            raise Collector.CollectError(\n                f\"Empty parameter set in '{func.__name__}' at line {lineno + 1}\"\n            )\n        case unreachable:\n            assert_never(unreachable)\n\n\nclass ParameterSet(NamedTuple):\n    \"\"\"A set of values for a set of parameters along with associated marks and\n    an optional ID for the set.\n\n    Examples::\n\n        pytest.param(1, 2, 3)\n        # ParameterSet(values=(1, 2, 3), marks=(), id=None)\n\n        pytest.param(\"hello\", id=\"greeting\")\n        # ParameterSet(values=(\"hello\",), marks=(), id=\"greeting\")\n","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/pytest-dev/pytest/blob/98b357f69e380da908740a212288d73b2ee06687/src/_pytest/mark/structures.py#L58-L94","documentation":"Raised as a `Collector.CollectError` during collection when a `@pytest.mark.parametrize` produces an empty parameter set (e.g. empty list of values) and the `empty_parameter_set_mark` ini option is set to `fail_at_collect`. The other valid values are `skip` (default) and `xfail`, which instead attach a mark and continue. With `fail_at_collect`, collection aborts on that test.","triggerScenarios":"@pytest.mark.parametrize('x', []) combined with `empty_parameter_set_mark = fail_at_collect` in pytest.ini / pyproject. Also when a generator/list comprehension yields no rows at runtime.","commonSituations":"Dynamically building parametrize values from an external source (CSV, DB query) that returns nothing; filtering out all rows; CI flag tightened to `fail_at_collect` to catch silent skips.","solutions":["Make the parametrize source non-empty, or guard the test so it is only collected when there is data.","If an empty set is legitimately possible, set `empty_parameter_set_mark = skip` (default) or `xfail`.","Generate the parameter list eagerly and assert it is non-empty before decorating, to fail with a clearer message."],"exampleFix":"# before\n@pytest.mark.parametrize('x', [])\ndef test_x(x): ...\n# after\ndata = load_rows()\n@pytest.mark.parametrize('x', data or [pytest.param(..., marks=pytest.mark.skip('no data'))])\ndef test_x(x): ...","handlingStrategy":"validation","validationCode":"def ensure_non_empty(values):\n    assert len(values) > 0, 'parametrize values are empty; fail_at_collect will abort'\n    return values","typeGuard":null,"tryCatchPattern":"try:\n    pytest.main([test_file])\nexcept Exception as e:\n    if 'Empty parameter set' in str(e):\n        ...","preventionTips":["Generate parametrize data eagerly and assert non-empty before decorating.","Prefer the default `empty_parameter_set_mark = skip` unless you intentionally want collection failure."],"tags":["pytest","parametrize","collection","config"],"analyzedSha":"98b357f69e380da908740a212288d73b2ee06687","analyzedAt":"2026-08-04T20:26:34.442Z","schemaVersion":2}