fixtures: use early return in `_get_active_fixturedef`
This commit is contained in:
parent
d208c1d4a5
commit
530be28575
|
@ -570,18 +570,21 @@ class FixtureRequest(abc.ABC):
|
||||||
self, argname: str
|
self, argname: str
|
||||||
) -> Union["FixtureDef[object]", PseudoFixtureDef[object]]:
|
) -> Union["FixtureDef[object]", PseudoFixtureDef[object]]:
|
||||||
fixturedef = self._fixture_defs.get(argname)
|
fixturedef = self._fixture_defs.get(argname)
|
||||||
if fixturedef is None:
|
if fixturedef is not None:
|
||||||
try:
|
|
||||||
fixturedef = self._getnextfixturedef(argname)
|
|
||||||
except FixtureLookupError:
|
|
||||||
if argname == "request":
|
|
||||||
cached_result = (self, [0], None)
|
|
||||||
return PseudoFixtureDef(cached_result, Scope.Function)
|
|
||||||
raise
|
|
||||||
self._compute_fixture_value(fixturedef)
|
|
||||||
self._fixture_defs[argname] = fixturedef
|
|
||||||
else:
|
|
||||||
self._check_scope(fixturedef, fixturedef._scope)
|
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
|
||||||
|
|
||||||
|
self._compute_fixture_value(fixturedef)
|
||||||
|
|
||||||
|
self._fixture_defs[argname] = fixturedef
|
||||||
return fixturedef
|
return fixturedef
|
||||||
|
|
||||||
def _get_fixturestack(self) -> List["FixtureDef[Any]"]:
|
def _get_fixturestack(self) -> List["FixtureDef[Any]"]:
|
||||||
|
|
Loading…
Reference in New Issue