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

Class TopRequest

src/_pytest/fixtures.py:771–809  ·  view source on GitHub ↗

The type of the ``request`` fixture in a test function.

Source from the content-addressed store, hash-verified

769
770@final
771class TopRequest(FixtureRequest):
772 """The type of the ``request`` fixture in a test function."""
773
774 def __init__(self, pyfuncitem: Function, *, _ispytest: bool = False) -> None:
775 super().__init__(
776 fixturename=None,
777 pyfuncitem=pyfuncitem,
778 arg2fixturedefs=pyfuncitem._fixtureinfo.name2fixturedefs,
779 fixture_defs={},
780 _ispytest=_ispytest,
781 )
782
783 @property
784 def _scope(self) -> Scope:
785 return Scope.Function
786
787 def _check_scope(
788 self,
789 requested_fixturedef: FixtureDef[object],
790 requested_scope: Scope,
791 ) -> None:
792 # TopRequest always has function scope so always valid.
793 pass
794
795 @property
796 def node(self):
797 return self._pyfuncitem
798
799 def __repr__(self) -> str:
800 return f"<FixtureRequest for {self.node!r}>"
801
802 def _fillfixtures(self) -> None:
803 item = self._pyfuncitem
804 for argname in item.fixturenames:
805 if argname not in item.funcargs:
806 item.funcargs[argname] = self.getfixturevalue(argname)
807
808 def addfinalizer(self, finalizer: Callable[[], object]) -> None:
809 self.node.addfinalizer(finalizer)
810
811
812@final

Calls

no outgoing calls