File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -1134,7 +1134,8 @@ def parametrize_plus_decorate(test_func):
11341134 # it is the same than existing, except that we want to replace all parameters with the new fixture
11351135
11361136 new_sig = remove_signature_parameters (old_sig , * all_param_names )
1137- new_sig = add_signature_parameters (new_sig , Parameter (base_name , kind = Parameter .POSITIONAL_OR_KEYWORD ))
1137+ # add it in last position, so that potential 'self' argument (case of test class methods) can stay first
1138+ new_sig = add_signature_parameters (new_sig , last = Parameter (base_name , kind = Parameter .POSITIONAL_OR_KEYWORD ))
11381139
11391140 # --Finally create the fixture function, a wrapper of user-provided fixture with the new signature
11401141 def replace_paramfixture_with_values (kwargs ):
Original file line number Diff line number Diff line change 1+ # test.py
2+ import pytest
3+ from pytest_cases import fixture_ref , pytest_parametrize_plus
4+
5+
6+ @pytest .fixture
7+ def foo ():
8+ return 1
9+
10+
11+ @pytest .fixture
12+ def bar ():
13+ return 2
14+
15+
16+ @pytest_parametrize_plus ("arg" , [fixture_ref ("foo" ), fixture_ref ("bar" )])
17+ def test_thing (arg ):
18+ print (arg )
19+
20+
21+ class TestCase :
22+ @pytest .mark .parametrize ("arg" , [1 , 2 ])
23+ def test_thing_pytest (self , arg ):
24+ print (arg )
25+
26+ @pytest_parametrize_plus ("arg" , [fixture_ref ("foo" ), fixture_ref ("bar" )])
27+ def test_thing_cases (self , arg ):
28+ print (arg )
You can’t perform that action at this time.
0 commit comments