{"record":{"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/0d6fbdeffa57c796123f62f81f7dd370d9b7ecdc/src/_pytest/mark/structures.py#L58-L94","documentation":"A Collector.CollectError raised when a parametrize call yields an empty parameter set and the ini option empty_parameter_set_mark is set to 'fail_at_collect'. By default pytest skips such tests; only this explicit configuration turns the empty set into a hard collection failure. The function name and 1-based line number are included so the user can locate the offending parametrize.","triggerScenarios":"A `@pytest.mark.parametrize('a', [])` decorator (or parametrize that evaluates to zero parameter rows) when pytest.ini / pyproject.toml sets `empty_parameter_set_mark = fail_at_collect`. Also triggered when a parametrize generator function yields nothing.","commonSituations":"Data-driven tests where the data source is empty at runtime (e.g. a filtered list, a weekend schedule, a disabled feature flag), combined with strict collection policy. CI configs that set fail_at_collect to surface empty suites.","solutions":["Supply at least one parameter row, or guard the parametrize call so it is only applied when data exists.","Change the ini option to 'skip' (default) or 'xfail' if an empty set is legitimate.","If the emptiness is a bug, fix the upstream data source / generator so it yields the expected rows."],"exampleFix":"# before\n@pytest.mark.parametrize('a', [])\ndef test_x(a): ...\n# after\n@pytest.mark.parametrize('a', [1])\ndef test_x(a): ...","handlingStrategy":"validation","validationCode":"def has_params(param_values) -> bool:\n    return len(list(param_values)) > 0","typeGuard":null,"tryCatchPattern":"import pytest\ntry:\n    # collection happens here\n    ...\nexcept pytest.Collector.CollectError as e:\n    if 'Empty parameter set' in str(e):\n        # provide default data or skip\n        ...","preventionTips":["Guard parametrize so it is only applied when data exists.","Prefer 'skip' (default) over 'fail_at_collect' unless you want strict CI.","Log when data sources are empty so you notice early."],"tags":["pytest","parametrize","collection-error","configuration","empty-parameter-set"],"backgroundTag":null,"analyzedSha":"0d6fbdeffa57c796123f62f81f7dd370d9b7ecdc","analyzedAt":"2026-08-11T20:52:36.969Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}