Skip to content

Commit d5eed3b

Browse files
committed
Pickup addition positional args passed to _parse_parametrize_ar… (#5483)
Pickup addition positional args passed to _parse_parametrize_args
1 parent 4b104ba commit d5eed3b

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ Kale Kundert
135135
Katarzyna Jachim
136136
Katerina Koukiou
137137
Kevin Cox
138+
Kevin J. Foley
138139
Kodi B. Arfer
139140
Kostis Anagnostopoulos
140141
Kristoffer Nordström

changelog/5482.bugfix.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix bug introduced in 4.6.0 causing collection errors when passing
2+
more than 2 positional arguments to ``pytest.mark.parametrize``.

src/_pytest/mark/structures.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,7 @@ def extract_from(cls, parameterset, force_tuple=False):
104104
return cls(parameterset, marks=[], id=None)
105105

106106
@staticmethod
107-
def _parse_parametrize_args(argnames, argvalues, **_):
108-
"""It receives an ignored _ (kwargs) argument so this function can
109-
take also calls from parametrize ignoring scope, indirect, and other
110-
arguments..."""
107+
def _parse_parametrize_args(argnames, argvalues, *args, **kwargs):
111108
if not isinstance(argnames, (tuple, list)):
112109
argnames = [x.strip() for x in argnames.split(",") if x.strip()]
113110
force_tuple = len(argnames) == 1

testing/python/metafunc.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1765,3 +1765,16 @@ def test_func_b(y):
17651765
result.stdout.fnmatch_lines(
17661766
["*test_func_a*0*PASS*", "*test_func_a*2*PASS*", "*test_func_b*10*PASS*"]
17671767
)
1768+
1769+
def test_parametrize_positional_args(self, testdir):
1770+
testdir.makepyfile(
1771+
"""
1772+
import pytest
1773+
1774+
@pytest.mark.parametrize("a", [1], False)
1775+
def test_foo(a):
1776+
pass
1777+
"""
1778+
)
1779+
result = testdir.runpytest()
1780+
result.assert_outcomes(passed=1)

0 commit comments

Comments
 (0)