Skip to content

Commit

Permalink
fixtures: move "request" check early
Browse files Browse the repository at this point in the history
  • Loading branch information
bluetech authored and nicoddemus committed Apr 27, 2024
1 parent d217d68 commit 3c77aec
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/_pytest/fixtures.py
Expand Up @@ -569,18 +569,18 @@ def _iter_chain(self) -> Iterator["SubRequest"]:
def _get_active_fixturedef(
self, argname: str
) -> Union["FixtureDef[object]", PseudoFixtureDef[object]]:
if argname == "request":
cached_result = (self, [0], None)
return PseudoFixtureDef(cached_result, Scope.Function)

# If we already finished computing a fixture by this name in this item,
# return it.
fixturedef = self._fixture_defs.get(argname)
if fixturedef is not None:
self._check_scope(fixturedef, fixturedef._scope)
return fixturedef

try:
fixturedef = self._getnextfixturedef(argname)
except FixtureLookupError:
if argname == "request":
cached_result = (self, [0], None)
return PseudoFixtureDef(cached_result, Scope.Function)
raise
fixturedef = self._getnextfixturedef(argname)

# Prepare a SubRequest object for calling the fixture.
funcitem = self._pyfuncitem
Expand Down

0 comments on commit 3c77aec

Please sign in to comment.