Skip to content

Commit 8a857a1

Browse files
committed
refactor: Removed event_loop_fixture_id from cache key of async fixtures.
1 parent e2a84ee commit 8a857a1

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

pytest_asyncio/plugin.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,8 @@ def _preprocess_async_fixtures(
238238
for fixtures in fixturemanager._arg2fixturedefs.values():
239239
for fixturedef in fixtures:
240240
func = fixturedef.func
241-
if not _is_coroutine_or_asyncgen(func) and not getattr(
242-
func, "_async_fixture", False
241+
if fixturedef in processed_fixturedefs or not _is_coroutine_or_asyncgen(
242+
func
243243
):
244244
continue
245245
if not _is_asyncio_fixture_function(func) and asyncio_mode == Mode.STRICT:
@@ -254,17 +254,12 @@ def _preprocess_async_fixtures(
254254
if scope == "function":
255255
event_loop_fixture_id: Optional[str] = "event_loop"
256256
else:
257-
try:
258-
event_loop_node = _retrieve_scope_root(collector, scope)
259-
except Exception:
260-
continue
257+
event_loop_node = _retrieve_scope_root(collector, scope)
261258
event_loop_fixture_id = event_loop_node.stash.get(
262259
# Type ignored because of non-optimal mypy inference.
263260
_event_loop_fixture_id, # type: ignore[arg-type]
264261
None,
265262
)
266-
if (fixturedef, event_loop_fixture_id) in processed_fixturedefs:
267-
continue
268263
_make_asyncio_fixture_function(func, scope)
269264
function_signature = inspect.signature(func)
270265
if "event_loop" in function_signature.parameters:
@@ -286,7 +281,7 @@ def _preprocess_async_fixtures(
286281
fixturedef.argnames += ("event_loop",)
287282
_synchronize_async_fixture(fixturedef)
288283
assert _is_asyncio_fixture_function(fixturedef.func)
289-
processed_fixturedefs.add((fixturedef, event_loop_fixture_id))
284+
processed_fixturedefs.add(fixturedef)
290285

291286

292287
def _synchronize_async_fixture(fixturedef: FixtureDef) -> None:

0 commit comments

Comments
 (0)