@@ -1521,6 +1521,20 @@ def getfixtureclosure(
1521
1521
# to re-discover fixturedefs again for each fixturename
1522
1522
# (discovering matching fixtures for a given name/node is expensive).
1523
1523
1524
+ def dependent_fixtures_argnames (
1525
+ fixture_defs : Sequence [FixtureDef [Any ]],
1526
+ ) -> List [str ]:
1527
+ last_fixture = fixture_defs [- 1 ]
1528
+ # Initialize with the argnames of the last fixture
1529
+ dependent_argnames = list (last_fixture .argnames )
1530
+ for arg in fixture_defs :
1531
+ if arg .argname in last_fixture .argnames :
1532
+ # Add new argument names maintaining order and avoiding duplicates
1533
+ for argname in arg .argnames :
1534
+ if argname not in dependent_argnames :
1535
+ dependent_argnames .append (argname )
1536
+ return dependent_argnames
1537
+
1524
1538
fixturenames_closure = list (initialnames )
1525
1539
1526
1540
arg2fixturedefs : Dict [str , Sequence [FixtureDef [Any ]]] = {}
@@ -1535,7 +1549,8 @@ def getfixtureclosure(
1535
1549
fixturedefs = self .getfixturedefs (argname , parentnode )
1536
1550
if fixturedefs :
1537
1551
arg2fixturedefs [argname ] = fixturedefs
1538
- for arg in fixturedefs [- 1 ].argnames :
1552
+ argnames = dependent_fixtures_argnames (fixturedefs )
1553
+ for arg in argnames :
1539
1554
if arg not in fixturenames_closure :
1540
1555
fixturenames_closure .append (arg )
1541
1556
0 commit comments