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

Method _check_scope

src/_pytest/fixtures.py:703–719  ·  view source on GitHub ↗
(
        self,
        argname: str,
        invoking_scope: Scope,
        requested_scope: Scope,
    )

Source from the content-addressed store, hash-verified

701 subrequest.node.addfinalizer(lambda: fixturedef.finish(request=subrequest))
702
703 def _check_scope(
704 self,
705 argname: str,
706 invoking_scope: Scope,
707 requested_scope: Scope,
708 ) -> None:
709 if argname == "request":
710 return
711 if invoking_scope > requested_scope:
712 # Try to report something helpful.
713 text = "\n".join(self._factorytraceback())
714 fail(
715 f"ScopeMismatch: You tried to access the {requested_scope.value} scoped "
716 f"fixture {argname} with a {invoking_scope.value} scoped request object, "
717 f"involved factories:\n{text}",
718 pytrace=False,
719 )
720
721 def _factorytraceback(self) -> List[str]:
722 lines = []

Callers 2

pytest_fixture_setupFunction · 0.80

Calls 2

_factorytracebackMethod · 0.95
failFunction · 0.90

Tested by

no test coverage detected