Skip to content

Commit f7de4d8

Browse files
tjkusonseifertm
authored andcommitted
Resolve fixture early
1 parent 323fadf commit f7de4d8

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

pytest_asyncio/plugin.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -546,16 +546,14 @@ def _can_substitute(item: Function) -> bool:
546546

547547
def setup(self) -> None:
548548
runner_fixture_id = f"_{self._loop_scope}_scoped_runner"
549-
if runner_fixture_id in self.fixturenames:
550-
return super().setup()
551-
# The runner must be resolved before async fixtures when loop
552-
# factories are configured. Otherwise, the async fixtures see a
553-
# stale loop from the previous factory.
549+
if runner_fixture_id not in self.fixturenames:
550+
self.fixturenames.append(runner_fixture_id)
551+
# When loop factories are configured, resolve the loop factory
552+
# fixture early so that a factory variant change cascades cache
553+
# invalidation before any async fixture checks its cache.
554554
hook_caller = self.config.hook.pytest_asyncio_loop_factories
555555
if hook_caller.get_hookimpls():
556-
self.fixturenames.insert(0, runner_fixture_id)
557-
else:
558-
self.fixturenames.append(runner_fixture_id)
556+
_ = self._request.getfixturevalue(_asyncio_loop_factory.__name__)
559557
return super().setup()
560558

561559
def runtest(self) -> None:

0 commit comments

Comments
 (0)