From 95714436a1ec29e01f017c914cee63970acdcb2a Mon Sep 17 00:00:00 2001 From: "Kevin J. Foley" Date: Mon, 24 Jun 2019 19:07:40 -0400 Subject: [PATCH] Pickup additional positional args passed to _parse_parametrize_args --- AUTHORS | 1 + changelog/5482.bugfix.rst | 2 ++ src/_pytest/mark/structures.py | 5 +---- testing/python/metafunc.py | 13 +++++++++++++ 4 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 changelog/5482.bugfix.rst diff --git a/AUTHORS b/AUTHORS index 3d050a346..087fce8d0 100644 --- a/AUTHORS +++ b/AUTHORS @@ -135,6 +135,7 @@ Kale Kundert Katarzyna Jachim Katerina Koukiou Kevin Cox +Kevin J. Foley Kodi B. Arfer Kostis Anagnostopoulos Kristoffer Nordström diff --git a/changelog/5482.bugfix.rst b/changelog/5482.bugfix.rst new file mode 100644 index 000000000..c345458d1 --- /dev/null +++ b/changelog/5482.bugfix.rst @@ -0,0 +1,2 @@ +Fix bug introduced in 4.6.0 causing collection errors when passing +more than 2 positional arguments to ``pytest.mark.parametrize``. diff --git a/src/_pytest/mark/structures.py b/src/_pytest/mark/structures.py index 39cdb57e4..1af7a9b42 100644 --- a/src/_pytest/mark/structures.py +++ b/src/_pytest/mark/structures.py @@ -102,10 +102,7 @@ class ParameterSet(namedtuple("ParameterSet", "values, marks, id")): return cls(parameterset, marks=[], id=None) @staticmethod - def _parse_parametrize_args(argnames, argvalues, **_): - """It receives an ignored _ (kwargs) argument so this function can - take also calls from parametrize ignoring scope, indirect, and other - arguments...""" + def _parse_parametrize_args(argnames, argvalues, *args, **kwargs): if not isinstance(argnames, (tuple, list)): argnames = [x.strip() for x in argnames.split(",") if x.strip()] force_tuple = len(argnames) == 1 diff --git a/testing/python/metafunc.py b/testing/python/metafunc.py index 6b26be72b..df93d4ef5 100644 --- a/testing/python/metafunc.py +++ b/testing/python/metafunc.py @@ -1761,3 +1761,16 @@ class TestMarkersWithParametrization: result.stdout.fnmatch_lines( ["*test_func_a*0*PASS*", "*test_func_a*2*PASS*", "*test_func_b*10*PASS*"] ) + + def test_parametrize_positional_args(self, testdir): + testdir.makepyfile( + """ + import pytest + + @pytest.mark.parametrize("a", [1], False) + def test_foo(a): + pass + """ + ) + result = testdir.runpytest() + result.assert_outcomes(passed=1)