Skip to content

Commit eaa8a2c

Browse files
committed
refactor: Simplified code in _preprocess_async_functions.
The code no longer determines the event_loop_fixture_id. This is now done inside the fixture synchronizers.
1 parent 8a857a1 commit eaa8a2c

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

pytest_asyncio/plugin.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -251,15 +251,8 @@ def _preprocess_async_fixtures(
251251
or default_loop_scope
252252
or fixturedef.scope
253253
)
254-
if scope == "function":
255-
event_loop_fixture_id: Optional[str] = "event_loop"
256-
else:
257-
event_loop_node = _retrieve_scope_root(collector, scope)
258-
event_loop_fixture_id = event_loop_node.stash.get(
259-
# Type ignored because of non-optimal mypy inference.
260-
_event_loop_fixture_id, # type: ignore[arg-type]
261-
None,
262-
)
254+
if scope == "function" and "event_loop" not in fixturedef.argnames:
255+
fixturedef.argnames += ("event_loop",)
263256
_make_asyncio_fixture_function(func, scope)
264257
function_signature = inspect.signature(func)
265258
if "event_loop" in function_signature.parameters:
@@ -271,14 +264,8 @@ def _preprocess_async_fixtures(
271264
f"instead."
272265
)
273266
)
274-
assert event_loop_fixture_id
275267
if "request" not in fixturedef.argnames:
276268
fixturedef.argnames += ("request",)
277-
if (
278-
event_loop_fixture_id == "event_loop"
279-
and "event_loop" not in fixturedef.argnames
280-
):
281-
fixturedef.argnames += ("event_loop",)
282269
_synchronize_async_fixture(fixturedef)
283270
assert _is_asyncio_fixture_function(fixturedef.func)
284271
processed_fixturedefs.add(fixturedef)

0 commit comments

Comments
 (0)