MCPcopy
hub / github.com/pytest-dev/pytest / FixtureDef

Class FixtureDef

src/_pytest/fixtures.py:1050–1245  ·  src/_pytest/fixtures.py::FixtureDef

A container for a fixture definition. Note: At this time, only explicitly documented fields and methods are considered public stable API.

Source from the content-addressed store, hash-verified

1048
1049
1050class FixtureDef(Generic[FixtureValue]):
1051 class="st">"""A container for a fixture definition.
1052
1053 Note: At this time, only explicitly documented fields and methods are
1054 considered public stable API.
1055 class="st">"""
1056
1057 def __init__(
1058 self,
1059 config: Config,
1060 baseid: str | None | NotSetType,
1061 argname: str,
1062 func: _FixtureFunc[FixtureValue],
1063 scope: Scope | ScopeName | Callable[[str, Config], ScopeName] | None,
1064 params: Sequence[object] | None,
1065 ids: tuple[object | None, ...] | Callable[[Any], object | None] | None = None,
1066 *,
1067 node: nodes.Node | NotSetType = NOTSET,
1068 class="cm"># only used in a deprecationwarning msg, can be removed in pytest9
1069 _autouse: bool = False,
1070 _ispytest: bool = False,
1071 ) -> None:
1072 check_ispytest(_ispytest)
1073 class="cm"># Emit deprecation warning if deprecated baseid string is used.
1074 if node is NOTSET:
1075 warnings.warn(FIXTURE_BASEID_DEPRECATED, stacklevel=2)
1076 if baseid is NOTSET:
1077 baseid = None
1078 class="cm"># The node where this fixture was defined, if available.
1079 class="cm"># Used for node-based matching which is more robust than string matching.
1080 self.node: Final = node if node is not NOTSET else None
1081 class="cm"># The class="st">"base" node ID for the fixture.
1082 class="cm">#
1083 class="cm"># This is a node ID prefix. A fixture is only available to a node (e.g.
1084 class="cm"># a `Function` item) if the fixture's baseid is a nodeid of a parent of
1085 class="cm"># node.
1086 class="cm">#
1087 class="cm"># For a fixture found in a Collector's object (e.g. a `Module`s module,
1088 class="cm"># a `Class`class="st">'s class), the baseid is the Collector's nodeid.
1089 class="cm">#
1090 class="cm"># For a fixture found in a conftest plugin, the baseid is the conftest's
1091 class="cm"># directory path relative to the rootdir.
1092 class="cm">#
1093 class="cm"># For other plugins, the baseid is the empty string (always matches).
1094 class="cm"># When node is available, baseid is derived from node.nodeid.
1095 class="cm">#
1096 class="cm"># Deprecated: replaced by ``node``.
1097 self.baseid: Final = node.nodeid if node is not NOTSET else (baseid or class="st">"")
1098 class="cm"># Whether the fixture was found from a node or a conftest in the
1099 class="cm"># collection tree. Will be false for fixtures defined in non-conftest
1100 class="cm"># plugins.
1101 class="cm">#
1102 class="cm"># Deprecated: kept only to back the deprecated ``has_location`` property.
1103 self._has_location: Final = node is not NOTSET or baseid is not None
1104 class="cm"># The fixture factory function.
1105 self.func: Final = func
1106 class="cm"># The name by which the fixture may be requested.
1107 self.argname: Final = argname

Callers 1

_register_fixtureMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected