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