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

Class FixtureDef

src/_pytest/fixtures.py:1050–1245  ·  view source on GitHub ↗

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 """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 """
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 # 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 # 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 # The node where this fixture was defined, if available.
1079 # 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 # The "base" node ID for the fixture.
1082 #
1083 # This is a node ID prefix. A fixture is only available to a node (e.g.
1084 # a `Function` item) if the fixture's baseid is a nodeid of a parent of
1085 # node.
1086 #
1087 # For a fixture found in a Collector's object (e.g. a `Module`s module,
1088 # a `Class`'s class), the baseid is the Collector's nodeid.
1089 #
1090 # For a fixture found in a conftest plugin, the baseid is the conftest's
1091 # directory path relative to the rootdir.
1092 #
1093 # For other plugins, the baseid is the empty string (always matches).
1094 # When node is available, baseid is derived from node.nodeid.
1095 #
1096 # Deprecated: replaced by ``node``.
1097 self.baseid: Final = node.nodeid if node is not NOTSET else (baseid or "")
1098 # Whether the fixture was found from a node or a conftest in the
1099 # collection tree. Will be false for fixtures defined in non-conftest
1100 # plugins.
1101 #
1102 # 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 # The fixture factory function.
1105 self.func: Final = func
1106 # 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

Used in the wild real call sites across dependent graphs

searching dependent graphs…