Skip to content

Commit f8b1fcc

Browse files
author
Sylvain MARIE
committed
Fixed issue caused by last fix, where the execution order was changed in many tests. Ready to tag
1 parent 487b19e commit f8b1fcc

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

pytest_cases/main_fixtures.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,10 +1132,16 @@ def parametrize_plus_decorate(test_func):
11321132

11331133
# --create the new test function's signature that we want to expose to pytest
11341134
# it is the same than existing, except that we want to replace all parameters with the new fixture
1135-
1135+
# first check where we should insert the new parameters (where is the first param we remove)
1136+
for _first_idx, _n in enumerate(old_sig.parameters):
1137+
if _n in all_param_names:
1138+
break
1139+
# then remove all parameters that will be replaced by the new fixture
11361140
new_sig = remove_signature_parameters(old_sig, *all_param_names)
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))
1141+
# finally insert the new fixture in that position. Indeed we can not insert first or last, because
1142+
# 'self' arg (case of test class methods) should stay first and exec order should be preserved when possible
1143+
new_sig = add_signature_parameters(new_sig, custom_idx=_first_idx,
1144+
custom=Parameter(base_name, kind=Parameter.POSITIONAL_OR_KEYWORD))
11391145

11401146
# --Finally create the fixture function, a wrapper of user-provided fixture with the new signature
11411147
def replace_paramfixture_with_values(kwargs):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
here = path.abspath(path.dirname(__file__))
1212

1313
# *************** Dependencies *********
14-
INSTALL_REQUIRES = ['wrapt', 'decopatch', 'makefun', 'functools32;python_version<"3.2"',
14+
INSTALL_REQUIRES = ['wrapt', 'decopatch', 'makefun>=1.7', 'functools32;python_version<"3.2"',
1515
'funcsigs;python_version<"3.3"', 'enum34;python_version<"3.4"', 'six']
1616
DEPENDENCY_LINKS = []
1717
SETUP_REQUIRES = ['pytest-runner', 'setuptools_scm', 'six']

0 commit comments

Comments
 (0)