Skip to content

Commit 6c575ad

Browse files
committed
fixtures: simplify FixtureRequest._get_fixturestack()
1 parent 73c4105 commit 6c575ad

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/_pytest/fixtures.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -607,14 +607,11 @@ def _get_active_fixturedef(
607607
def _get_fixturestack(self) -> List["FixtureDef[Any]"]:
608608
current = self
609609
values: List[FixtureDef[Any]] = []
610-
while 1:
611-
fixturedef = getattr(current, "_fixturedef", None)
612-
if fixturedef is None:
613-
values.reverse()
614-
return values
615-
values.append(fixturedef)
616-
assert isinstance(current, SubRequest)
610+
while isinstance(current, SubRequest):
611+
values.append(current._fixturedef) # type: ignore[has-type]
617612
current = current._parent_request
613+
values.reverse()
614+
return values
618615

619616
def _compute_fixture_value(self, fixturedef: "FixtureDef[object]") -> None:
620617
"""Create a SubRequest based on "self" and call the execute method

0 commit comments

Comments
 (0)