diff --git a/src/_balder/collector.py b/src/_balder/collector.py index 1b6e7bd..21d089a 100644 --- a/src/_balder/collector.py +++ b/src/_balder/collector.py @@ -58,6 +58,18 @@ def __init__(self, working_dir: pathlib.Path): self.balderglob_was_loaded = False + @staticmethod + def register_raw_fixture(fixture: Callable, level: str): + """ + allows to register a new fixture - used by decorator `@balder.fixture()` + + :param level: the fixture level + :param fixture: the fixture callable itself + """ + if level not in Collector._raw_fixtures.keys(): + Collector._raw_fixtures[level] = [] + Collector._raw_fixtures[level].append(fixture) + @staticmethod def register_possible_method_variation( meth: Callable, diff --git a/src/_balder/decorator_fixture.py b/src/_balder/decorator_fixture.py index 56efd0b..9da0e6b 100644 --- a/src/_balder/decorator_fixture.py +++ b/src/_balder/decorator_fixture.py @@ -18,11 +18,8 @@ def fixture(level: Literal['session', 'setup', 'scenario', 'variation', 'testcas raise ValueError(f"the value of `level` must be a `str` with one of the values `{'`, `'.join(allowed_levels)}`") def decorator_fixture(func): - # always add the fixture to FixtureManager.raw_fixtures - class determination will be done later by - # :meth:`Collector` - if level not in Collector._raw_fixtures.keys(): - Collector._raw_fixtures[level] = [] - Collector._raw_fixtures[level].append(func) + # always register the raw fixture in Collector - class determination will be done later by :meth:`Collector` + Collector.register_raw_fixture(func, level) @functools.wraps(func) def wrapper_fixture(*args, **kwargs):