File tree 2 files changed +26
-0
lines changed
2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -114,6 +114,18 @@ Let's run this::
114
114
The one parameter set which caused a failure previously now
115
115
shows up as an "xfailed (expected to fail)" test.
116
116
117
+ To get all combinations of multiple parametrized arguments you can stack
118
+ ``parametrize`` decorators::
119
+
120
+ import pytest
121
+ @pytest.mark.parametrize("x", [0, 1])
122
+ @pytest.mark.parametrize("y", [2, 3])
123
+ def test_foo(x, y):
124
+ pass
125
+
126
+ This will run the test with the arguments set to x=0/y=2, x=0/y=3, x=1/y=2 and
127
+ x=1/y=3.
128
+
117
129
.. note::
118
130
119
131
In versions prior to 2.4 one needed to specify the argument
Original file line number Diff line number Diff line change @@ -472,6 +472,20 @@ def pytest_pyfunc_call(self, pyfuncitem):
472
472
config .pluginmanager .register (MyPlugin2 ())
473
473
config .hook .pytest_pyfunc_call (pyfuncitem = item )
474
474
475
+ def test_multiple_parametrize (self , testdir ):
476
+ modcol = testdir .getmodulecol ("""
477
+ import pytest
478
+ @pytest.mark.parametrize('x', [0, 1])
479
+ @pytest.mark.parametrize('y', [2, 3])
480
+ def test1(x, y):
481
+ pass
482
+ """ )
483
+ colitems = modcol .collect ()
484
+ assert colitems [0 ].name == 'test1[2-0]'
485
+ assert colitems [1 ].name == 'test1[2-1]'
486
+ assert colitems [2 ].name == 'test1[3-0]'
487
+ assert colitems [3 ].name == 'test1[3-1]'
488
+
475
489
def test_issue751_multiple_parametrize_with_ids (self , testdir ):
476
490
modcol = testdir .getmodulecol ("""
477
491
import pytest
You can’t perform that action at this time.
0 commit comments