Skip to content

Commit 6c515a2

Browse files
author
Sylvain MARIE
committed
Minor: improved _create_param_fixture now raises an exception if auto_simplify=True and the provided argvalue is marked using pytest.param.
1 parent 31710ca commit 6c515a2

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

pytest_cases/fixture_core2.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@ def _create_param_fixture(fixtures_dest,
102102
# Simplification: do not parametrize the fixture, it will directly return the single value
103103
argvalue_to_return = argvalues[0]
104104
if is_marked_parameter_value(argvalue_to_return):
105-
argvalue_to_return = get_marked_parameter_values(argvalue_to_return)
105+
# Warning in that case the argvalues should not be a pytest.param.
106+
# argvalue_to_return = get_marked_parameter_values(argvalue_to_return)
107+
raise ValueError("When auto_simplify=True the argvalue can not be a pytest.param")
106108

107109
# create the fixture - set its name so that the optional hook can read it easily
108110
@with_signature("%s()" % argname)

pytest_cases/fixture_parametrize_plus.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ def _create_params_alt(fh, test_func_name, union_name, from_i, to_i, hook): # n
529529
print(" - Creating new fixture %r to handle parameter %s" % (p_fix_name, i))
530530

531531
# Create the fixture that will return the unique parameter value ("auto-simplify" flag)
532-
# IMPORTANT that fixture is NOT parametrized so has no id nor marks: use argvalues not marked_argvalues
532+
# IMPORTANT auto_simplify=True we create a NON-parametrized fixture. use argvalues not marked_argvalues
533533
_create_param_fixture(fh, argname=p_fix_name, argvalues=argvalues[i:i + 1], hook=hook, auto_simplify=True)
534534

535535
# Create the alternative

0 commit comments

Comments
 (0)