diff --git a/changelog/14795.bugfix.rst b/changelog/14795.bugfix.rst new file mode 100644 index 00000000000..337e6727655 --- /dev/null +++ b/changelog/14795.bugfix.rst @@ -0,0 +1 @@ +Handle non-tuple and non-list parameter items cleanly in :meth:`ParameterSet.extract_from` when single parameter names use trailing commas in :func:`pytest.mark.parametrize`. diff --git a/src/_pytest/mark/structures.py b/src/_pytest/mark/structures.py index 5449b17a1c6..488ceebc0a2 100644 --- a/src/_pytest/mark/structures.py +++ b/src/_pytest/mark/structures.py @@ -154,13 +154,10 @@ def extract_from( return parameterset if force_tuple: return cls.param(parameterset) + elif isinstance(parameterset, (tuple, list)): + return cls(parameterset, marks=[], id=None) else: - # TODO: Refactor to fix this type-ignore. Currently the following - # passes type-checking but crashes: - # - # @pytest.mark.parametrize(('x', 'y'), [1, 2]) - # def test_foo(x, y): pass - return cls(parameterset, marks=[], id=None) # type: ignore[arg-type] + return cls((parameterset,), marks=[], id=None) @staticmethod def _parse_parametrize_args(