@@ -1505,6 +1505,20 @@ def getfixtureclosure(
1505
1505
# to re-discover fixturedefs again for each fixturename
1506
1506
# (discovering matching fixtures for a given name/node is expensive).
1507
1507
1508
+ def dependent_fixtures_argnames (
1509
+ fixture_defs : Sequence [FixtureDef [Any ]],
1510
+ ) -> List [str ]:
1511
+ last_fixture = fixture_defs [- 1 ]
1512
+ # Initialize with the argnames of the last fixture
1513
+ dependent_argnames = list (last_fixture .argnames )
1514
+ for arg in fixture_defs :
1515
+ if arg .argname in last_fixture .argnames :
1516
+ # Add new argument names maintaining order and avoiding duplicates
1517
+ for argname in arg .argnames :
1518
+ if argname not in dependent_argnames :
1519
+ dependent_argnames .append (argname )
1520
+ return dependent_argnames
1521
+
1508
1522
fixturenames_closure = list (initialnames )
1509
1523
1510
1524
arg2fixturedefs : Dict [str , Sequence [FixtureDef [Any ]]] = {}
@@ -1519,7 +1533,8 @@ def getfixtureclosure(
1519
1533
fixturedefs = self .getfixturedefs (argname , parentnode )
1520
1534
if fixturedefs :
1521
1535
arg2fixturedefs [argname ] = fixturedefs
1522
- for arg in fixturedefs [- 1 ].argnames :
1536
+ argnames = dependent_fixtures_argnames (fixturedefs )
1537
+ for arg in argnames :
1523
1538
if arg not in fixturenames_closure :
1524
1539
fixturenames_closure .append (arg )
1525
1540
0 commit comments