change param_index for pseudofixturedef
This commit is contained in:
parent
03e54712dd
commit
0b6028f748
|
@ -1326,10 +1326,12 @@ class Metafunc:
|
|||
# more than once) then we accumulate those calls generating the cartesian product
|
||||
# of all calls.
|
||||
newcalls = []
|
||||
for callspec in self._calls or [CallSpec2()]:
|
||||
for callspec_index, callspec in enumerate(self._calls or [CallSpec2()]):
|
||||
for param_index, (param_id, param_set) in enumerate(
|
||||
zip(ids, parametersets)
|
||||
):
|
||||
if name2pseudofixturedef:
|
||||
param_index = callspec_index + param_index
|
||||
newcallspec = callspec.setmulti(
|
||||
argnames=argnames,
|
||||
valset=param_set.values,
|
||||
|
|
|
@ -1019,6 +1019,35 @@ class TestMetafunc:
|
|||
]
|
||||
)
|
||||
|
||||
def test_multi_parametrize_reordering(self, pytester: Pytester) -> None:
|
||||
pytester.makepyfile(
|
||||
"""
|
||||
import pytest
|
||||
|
||||
@pytest.mark.parametrize("arg2", ['a', 'b'], scope='class')
|
||||
@pytest.mark.parametrize("arg1", [1, 2], scope='class')
|
||||
class TestClass:
|
||||
def test1(self, arg1, arg2):
|
||||
pass
|
||||
|
||||
def test2(self, arg1, arg2):
|
||||
pass
|
||||
"""
|
||||
)
|
||||
result = pytester.runpytest("--collect-only")
|
||||
result.stdout.re_match_lines(
|
||||
[
|
||||
r" <Function test1\[1-a\]>",
|
||||
r" <Function test2\[1-a\]>",
|
||||
r" <Function test1\[1-b\]>",
|
||||
r" <Function test2\[1-b\]>",
|
||||
r" <Function test1\[2-a\]>",
|
||||
r" <Function test2\[2-a\]>",
|
||||
r" <Function test1\[2-b\]>",
|
||||
r" <Function test2\[2-b\]>",
|
||||
]
|
||||
)
|
||||
|
||||
def test_parametrize_multiple_times(self, pytester: Pytester) -> None:
|
||||
pytester.makepyfile(
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue