Skip to content

Commit 6415c41

Browse files
author
Sylvain MARIE
committed
Changed the order of the current_cases dict so that the fixtures are at the end. Replaced the entries in current_cases with named tuples.
1 parent 0bd6c0c commit 6415c41

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

pytest_cases/case_parametrizer_new.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
# Use true division operator always even in old python 2.x (used in `_extract_cases_from_module`)
66
from __future__ import division
77

8+
from collections import namedtuple
9+
810
import functools
911
from importlib import import_module
1012
from inspect import getmembers, ismodule
@@ -1005,6 +1007,9 @@ def get_current_param(value, argname_or_fixturename, mp_fix_to_args):
10051007
return argnames, actual_value, parametrized
10061008

10071009

1010+
Case = namedtuple("Case", ("id", "func", "params"))
1011+
1012+
10081013
def get_current_cases(request_or_item):
10091014
"""
10101015
Returns a dictionary containing all case parameters for the currently active `pytest` item.
@@ -1077,7 +1082,7 @@ def _do(name, value, dct, preserve=False):
10771082
pass
10781083

10791084
# Finally fill the results
1080-
dct[name] = (case_id, case_func, case_params_dct)
1085+
dct[name] = Case(case_id, case_func, case_params_dct)
10811086

10821087
elif preserve:
10831088
# used in nested scenarii
@@ -1105,9 +1110,12 @@ def _do(name, value, dct, preserve=False):
11051110
except KeyError:
11061111
pass
11071112

1108-
# merge the two
1109-
cases_res_dict_fixs.update(cases_res_dict)
1110-
return cases_res_dict_fixs
1113+
# merge the two - put the fixtures at the end
1114+
for k, v in cases_res_dict_fixs.items():
1115+
if k not in cases_res_dict:
1116+
cases_res_dict[k] = v
1117+
1118+
return cases_res_dict
11111119

11121120

11131121
def _get_place_as(f):

0 commit comments

Comments
 (0)