Skip to content

Commit 3c77aec

Browse files
bluetechnicoddemus
authored andcommitted
fixtures: move "request" check early
1 parent d217d68 commit 3c77aec

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/_pytest/fixtures.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -569,18 +569,18 @@ def _iter_chain(self) -> Iterator["SubRequest"]:
569569
def _get_active_fixturedef(
570570
self, argname: str
571571
) -> Union["FixtureDef[object]", PseudoFixtureDef[object]]:
572+
if argname == "request":
573+
cached_result = (self, [0], None)
574+
return PseudoFixtureDef(cached_result, Scope.Function)
575+
576+
# If we already finished computing a fixture by this name in this item,
577+
# return it.
572578
fixturedef = self._fixture_defs.get(argname)
573579
if fixturedef is not None:
574580
self._check_scope(fixturedef, fixturedef._scope)
575581
return fixturedef
576582

577-
try:
578-
fixturedef = self._getnextfixturedef(argname)
579-
except FixtureLookupError:
580-
if argname == "request":
581-
cached_result = (self, [0], None)
582-
return PseudoFixtureDef(cached_result, Scope.Function)
583-
raise
583+
fixturedef = self._getnextfixturedef(argname)
584584

585585
# Prepare a SubRequest object for calling the fixture.
586586
funcitem = self._pyfuncitem

0 commit comments

Comments
 (0)