Skip to content

Commit 6801c91

Browse files
author
Sylvain MARIE
committed
Replaced the "used" parameter with a dedicated singleton USED
1 parent 8950e65 commit 6801c91

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

pytest_cases/fixture_core1_unions.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,19 @@ def __repr__(self):
3333
return "pytest_cases.NOT_USED"
3434

3535

36+
class _Used:
37+
def __repr__(self):
38+
return "pytest_cases.USED"
39+
40+
3641
NOT_USED = _NotUsed()
3742
"""Object representing a fixture value when the fixture is not used"""
3843

3944

45+
USED = _Used()
46+
"""Object representing a fixture value when the fixture is used"""
47+
48+
4049
class UnionIdMakers(object):
4150
"""
4251
The enum defining all possible id styles for union fixture parameters ("alternatives")

pytest_cases/plugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
from .common_pytest import get_pytest_nodeid, get_pytest_function_scopenum, is_function_node, get_param_names, \
3232
get_param_argnames_as_list
3333

34-
from .fixture_core1_unions import NOT_USED, is_fixture_union_params, UnionFixtureAlternative
34+
from .fixture_core1_unions import NOT_USED, USED, is_fixture_union_params, UnionFixtureAlternative
3535

3636
# if PYTEST54_OR_GREATER:
3737
# # we will need to clean the empty ids explicitly in the plugin :'(
@@ -1075,7 +1075,7 @@ def _cleanup_calls_list(metafunc,
10751075
c._arg2scopenum[fixture_name] = _function_scope_num # get_pytest_scopenum(fixdef[-1].scope) # noqa
10761076
else:
10771077
# explicitly add it as active
1078-
c.params[fixture_name] = 'used'
1078+
c.params[fixture_name] = USED
10791079
c.indices[fixture_name] = 0
10801080
c._arg2scopenum[fixture_name] = _function_scope_num # get_pytest_scopenum(fixdef[-1].scope) # noqa
10811081

0 commit comments

Comments
 (0)