Skip to content

Commit bfaa91c

Browse files
author
Sylvain MARIE
committed
New decorator @pytest_parametrize_plus able to handle the case where a fixture_ref(<fixture_name>) is present in the parameter values list. This decorator can be applied both on test functions and fixtures (if they are decorated with @pytest_fixture_plus). Fixes #40
Added appropriate test. Major refactoring of the "union fixtures" mechanism. - The `NOT_USED` status is now correctly propagated between dependent fixtures. This should fix a few cases where user fixtures were setup/teardown while not used in the current test node. - Empty fixture unions are not permitted anymore. - The way unions are handled in parametrization was redesigned. The new design is based on a two-steps approach: first build the closure as a tree, and then apply parametrization based on this tree. This fixes several unintuitive behaviours. Internal: - A new internal function `is_used_request(request)` is used everywhere to check if a request for a fixture is actually used or not. In which case user code is not called. - `UnionFixtureConfig` renamed `UnionFixtureAlternative` and the parametrization of a union fixture now contains the correct number of items. New associated helper `is_fixture_union_params`
1 parent 6713065 commit bfaa91c

File tree

5 files changed

+951
-554
lines changed

5 files changed

+951
-554
lines changed

pytest_cases/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from pytest_cases.case_funcs import case_name, test_target, case_tags, cases_generator
22

33
from pytest_cases.main_fixtures import cases_fixture, pytest_fixture_plus, param_fixtures, param_fixture, \
4-
fixture_union, NOT_USED # pytest_parametrize_plus
4+
fixture_union, NOT_USED, pytest_parametrize_plus, fixture_ref
55

66
from pytest_cases.main_params import cases_data, CaseDataGetter, unfold_expected_err, get_all_cases, THIS_MODULE, \
77
get_pytest_parametrize_args
@@ -14,7 +14,7 @@
1414
'case_name', 'test_target', 'case_tags', 'cases_generator',
1515
# --main_fixtures
1616
'cases_fixture', 'pytest_fixture_plus', 'param_fixtures', 'param_fixture', # 'pytest_parametrize_plus',
17-
'fixture_union', 'NOT_USED',
17+
'fixture_union', 'NOT_USED', 'pytest_parametrize_plus', 'fixture_ref',
1818
# --main params
1919
'cases_data', 'CaseDataGetter', 'THIS_MODULE', 'unfold_expected_err', 'get_all_cases',
2020
'get_pytest_parametrize_args',

pytest_cases/common.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,3 +293,10 @@ def transform_marks_into_decorators(marks):
293293
except Exception as e:
294294
warn("Caught exception while trying to mark case: [%s] %s" % (type(e), e))
295295
return marks_mod
296+
297+
298+
def get_pytest_nodeid(metafunc):
299+
try:
300+
return metafunc.definition.nodeid
301+
except AttributeError:
302+
return "unknown"

0 commit comments

Comments
 (0)