Skip to content

Commit b86aea6

Browse files
committed
Add is_fixture function
1 parent 7a040d4 commit b86aea6

File tree

5 files changed

+22
-3
lines changed

5 files changed

+22
-3
lines changed

reframe/core/fixtures.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,8 @@ def instantiate_all(self):
288288

289289
try:
290290
# Instantiate the fixture
291-
inst = cls(variant_num=varnum, variables=fixtvars)
291+
inst = cls(variant_num=varnum, variables=fixtvars,
292+
is_fixture=True)
292293
except Exception:
293294
exc_info = sys.exc_info()
294295
getlogger().warning(

reframe/core/meta.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,9 @@ def __call__(cls, *args, **kwargs):
487487
if not isinstance(variables, collections.abc.Mapping):
488488
raise TypeError("'variables' argument must be a mapping")
489489

490+
# Intercept is_fixture argument to flag an instance as a fixture
491+
is_fixture = kwargs.pop('is_fixture', False)
492+
490493
obj = cls.__new__(cls, *args, **kwargs)
491494

492495
# Insert the var and param spaces
@@ -499,6 +502,10 @@ def __call__(cls, *args, **kwargs):
499502
obj._rfm_param_variant = param_index
500503
obj._rfm_fixt_variant = fixt_index
501504

505+
# Flag the instance as fixture
506+
if is_fixture:
507+
obj._rfm_is_fixture = True
508+
502509
# Set the variables passed to the constructor
503510
for k, v in variables.items():
504511
if k in cls.var_space:

reframe/core/pipeline.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,6 +1243,10 @@ def is_local(self):
12431243

12441244
return self.local or self._current_partition.scheduler.is_local
12451245

1246+
def is_fixture(self):
1247+
'''Check if the test is a fixture.'''
1248+
return getattr(self, '_rfm_is_fixture', False)
1249+
12461250
def _resolve_fixtures(self):
12471251
'''Resolve the fixture dependencies and inject the fixture handle.
12481252

reframe/frontend/cli.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,10 @@ def list_checks(testcases, printer, detailed=False):
116116
deps.setdefault(t.check.name, [])
117117
deps[t.check.name].append((t, t.deps))
118118

119-
checks = set(t.check for t in testcases)
119+
checks = set(
120+
t.check for t in testcases
121+
if detailed or not t.check.is_fixture()
122+
)
120123
printer.info(
121124
'\n'.join(format_check(c, deps[c.name], detailed) for c in checks)
122125
)

unittests/resources/checks_unlisted/fixtures_complex.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ def validate_fixture_resolution(self):
6161
# Assert that there are only 4 underlying fixture instances.
6262
sn.assert_eq(
6363
sn.len({self.f0, self.f1, self.f2, self.f3, *self.f4}), 4
64-
)
64+
),
65+
66+
# Assert is_fixture() function
67+
sn.assert_true(self.f0.is_fixture()),
68+
sn.assert_false(self.is_fixture())
6569
])
6670

6771

0 commit comments

Comments
 (0)