Utilities for attaching typed marks to pytest fixture functions and querying those marks during a test session.
Use :func:mark to store an info object on the original function. Use :func:get_infos to retrieve fixtures tagged with a particular info type among those visible to a request.
Marks are independent of @pytest.fixture: apply the mark to the original function, then wrap with @pytest.fixture.
Functions | |
| Callable[..., object] | mark (Callable[..., object] func, object info) |
| Attach info to the original function func. | |
| dict[str, I] | get_infos (pytest.FixtureRequest request, type[I] info_type) |
| Return marked fixtures of info_type that are visible to a request. | |
| bool | _is_pytest_fixture_wrapper (object func) |
| Sequence[Any]|None | _get_fixturedefs (Any fixture_manager, str name, pytest.FixtureRequest request) |
| Iterator[pytest.FixtureDef[Any]] | _iter_visible_fixtures (pytest.FixtureRequest request) |
Variables | |
| I = TypeVar('I') | |
| str | _MARKS_ATTR = '_testsuite_fixture_marks' |
| dict | _SCOPE_RANK |
|
protected |
Definition at line 123 of file fixture_markers.py.
|
protected |
Definition at line 117 of file fixture_markers.py.
|
protected |
Definition at line 134 of file fixture_markers.py.
| dict[str, I] get_infos | ( | pytest.FixtureRequest | request, |
| type[I] | info_type ) |
Return marked fixtures of info_type that are visible to a request.
Walks fixture definitions known to pytest, keeps those applicable to the requesting test, and skips fixtures whose scope is narrower than request.scope.
Only the winning fixture definition is inspected. An override must carry its own mark; a parent mark is not inherited.
See :doc:fixture_markers for usage examples.
:param request: The pytest fixture request object. :param info_type: The info class whose tagged fixtures you want to look up. :returns: dict[str, I] mapping each tagged fixture's name to the info object that was passed to :func:mark. The dict is a fresh copy; mutating it has no effect on stored data.
Definition at line 81 of file fixture_markers.py.
| Callable[..., object] mark | ( | Callable[..., object] | func, |
| object | info ) |
Attach info to the original function func.
Creates the marks dict if it is missing, otherwise updates it. The info type is the lookup key for :func:get_infos. Each type may be attached at most once.
func must be the original function, not a @pytest.fixture wrapper. Apply the mark under @pytest.fixture.
See :doc:fixture_markers for usage examples.
:param func: The original fixture function. :param info: Metadata instance to store. :returns: func, unchanged.
Definition at line 38 of file fixture_markers.py.
|
protected |
Definition at line 28 of file fixture_markers.py.
|
protected |
Definition at line 29 of file fixture_markers.py.
| testsuite.fixture_markers.I = TypeVar('I') |
Definition at line 26 of file fixture_markers.py.