fixtures: avoid using the mildly expensive `fixturenames` property

Avoid creating a list copy + 2 sets + a linear search through the list
(in the common case).
This commit is contained in:
Ran Benita 2023-09-01 15:36:41 +03:00
parent b8906b29a7
commit 574e0f45d9
1 changed files with 4 additions and 1 deletions

View File

@ -791,7 +791,10 @@ class SubRequest(FixtureRequest):
# If the executing fixturedef was not explicitly requested in the argument list (via
# getfixturevalue inside the fixture call) then ensure this fixture def will be finished
# first.
if fixturedef.argname not in self.fixturenames:
if (
fixturedef.argname not in self._fixture_defs
and fixturedef.argname not in self._pyfuncitem.fixturenames
):
fixturedef.addfinalizer(
functools.partial(self._fixturedef.finish, request=self)
)