Pickup addition positional args passed to _parse_parametrize_ar… (#5483)

Pickup addition positional args passed to _parse_parametrize_args
This commit is contained in:
Bruno Oliveira 2019-06-24 22:05:19 -03:00 committed by GitHub
commit 37fce6c6e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 4 deletions

View File

@ -135,6 +135,7 @@ Kale Kundert
Katarzyna Jachim Katarzyna Jachim
Katerina Koukiou Katerina Koukiou
Kevin Cox Kevin Cox
Kevin J. Foley
Kodi B. Arfer Kodi B. Arfer
Kostis Anagnostopoulos Kostis Anagnostopoulos
Kristoffer Nordström Kristoffer Nordström

View File

@ -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``.

View File

@ -102,10 +102,7 @@ class ParameterSet(namedtuple("ParameterSet", "values, marks, id")):
return cls(parameterset, marks=[], id=None) return cls(parameterset, marks=[], id=None)
@staticmethod @staticmethod
def _parse_parametrize_args(argnames, argvalues, **_): def _parse_parametrize_args(argnames, argvalues, *args, **kwargs):
"""It receives an ignored _ (kwargs) argument so this function can
take also calls from parametrize ignoring scope, indirect, and other
arguments..."""
if not isinstance(argnames, (tuple, list)): if not isinstance(argnames, (tuple, list)):
argnames = [x.strip() for x in argnames.split(",") if x.strip()] argnames = [x.strip() for x in argnames.split(",") if x.strip()]
force_tuple = len(argnames) == 1 force_tuple = len(argnames) == 1

View File

@ -1761,3 +1761,16 @@ class TestMarkersWithParametrization:
result.stdout.fnmatch_lines( result.stdout.fnmatch_lines(
["*test_func_a*0*PASS*", "*test_func_a*2*PASS*", "*test_func_b*10*PASS*"] ["*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)