@@ -1521,6 +1521,20 @@ def getfixtureclosure(
15211521 # to re-discover fixturedefs again for each fixturename
15221522 # (discovering matching fixtures for a given name/node is expensive).
15231523
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+
15241538 fixturenames_closure = list (initialnames )
15251539
15261540 arg2fixturedefs : Dict [str , Sequence [FixtureDef [Any ]]] = {}
@@ -1535,7 +1549,8 @@ def getfixtureclosure(
15351549 fixturedefs = self .getfixturedefs (argname , parentnode )
15361550 if fixturedefs :
15371551 arg2fixturedefs [argname ] = fixturedefs
1538- for arg in fixturedefs [- 1 ].argnames :
1552+ argnames = dependent_fixtures_argnames (fixturedefs )
1553+ for arg in argnames :
15391554 if arg not in fixturenames_closure :
15401555 fixturenames_closure .append (arg )
15411556
0 commit comments