MCPcopy Create free account
hub / github.com/pytest-dev/pytest / __init__

Method __init__

src/_pytest/fixtures.py:969–1007  ·  view source on GitHub ↗
(
        self,
        fixturemanager: "FixtureManager",
        baseid: Optional[str],
        argname: str,
        func: "_FixtureFunc[FixtureValue]",
        scope: Union[Scope, "_ScopeName", Callable[[str, Config], "_ScopeName"], None],
        params: Optional[Sequence[object]],
        unittest: bool = False,
        ids: Optional[
            Union[
                Tuple[Union[None, str, float, int, bool], ...],
                Callable[[Any], Optional[object]],
            ]
        ] = None,
    )

Source from the content-addressed store, hash-verified

967 """A container for a factory definition."""
968
969 def __init__(
970 self,
971 fixturemanager: "FixtureManager",
972 baseid: Optional[str],
973 argname: str,
974 func: "_FixtureFunc[FixtureValue]",
975 scope: Union[Scope, "_ScopeName", Callable[[str, Config], "_ScopeName"], None],
976 params: Optional[Sequence[object]],
977 unittest: bool = False,
978 ids: Optional[
979 Union[
980 Tuple[Union[None, str, float, int, bool], ...],
981 Callable[[Any], Optional[object]],
982 ]
983 ] = None,
984 ) -> None:
985 self._fixturemanager = fixturemanager
986 self.baseid = baseid or ""
987 self.has_location = baseid is not None
988 self.func = func
989 self.argname = argname
990 if scope is None:
991 scope = Scope.Function
992 elif callable(scope):
993 scope = _eval_scope_callable(scope, argname, fixturemanager.config)
994
995 if isinstance(scope, str):
996 scope = Scope.from_user(
997 scope, descr=f"Fixture '{func.__name__}'", where=baseid
998 )
999 self._scope = scope
1000 self.params: Optional[Sequence[object]] = params
1001 self.argnames: Tuple[str, ...] = getfuncargnames(
1002 func, name=argname, is_method=unittest
1003 )
1004 self.unittest = unittest
1005 self.ids = ids
1006 self.cached_result: Optional[_FixtureCachedResult[FixtureValue]] = None
1007 self._finalizers: List[Callable[[], object]] = []
1008
1009 @property
1010 def scope(self) -> "_ScopeName":

Callers

nothing calls this directly

Calls 3

getfuncargnamesFunction · 0.90
_eval_scope_callableFunction · 0.85
from_userMethod · 0.80

Tested by

no test coverage detected