From 478fdba1b298abe9cb4c581514ca328f13727faf Mon Sep 17 00:00:00 2001 From: Yuri Konotopov Date: Sun, 23 Aug 2026 13:07:12 +0400 Subject: [PATCH] tests: do not use event_loop fixture It was removed from latest version of pytest-asyncio Signed-off-by: Yuri Konotopov Forwarded: https://github.com/mosquito/aiofile/pull/113 Applied-Upstream: https://github.com/mosquito/aiofile/commit/04f06a095733e424bad71ecc45b13a2d4eb4f1f2 --- tests/conftest.py | 7 +++++-- tests/test_aio.py | 12 ++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 00a75e5..8cb68c1 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,3 +1,4 @@ +import asyncio from functools import partial from types import ModuleType from typing import List, Union @@ -46,12 +47,14 @@ IMPLEMENTATION_NAMES: List[str] = list( @pytest.fixture(params=IMPLEMENTATIONS, ids=IMPLEMENTATION_NAMES) -async def aio_context(request, event_loop): +async def aio_context(request): if request.param is None: yield None return - async with request.param.AsyncioContext(loop=event_loop) as context: + async with request.param.AsyncioContext( + loop=asyncio.get_event_loop() + ) as context: yield context diff --git a/tests/test_aio.py b/tests/test_aio.py index e467145..60f9caa 100644 --- a/tests/test_aio.py +++ b/tests/test_aio.py @@ -387,9 +387,9 @@ async def test_write_read_nothing(aio_file_maker, temp_file, mode, data): assert await afp.read() == data -async def test_partial_writes(temp_file, event_loop): +async def test_partial_writes(temp_file): ctx = Mock(caio.AbstractContext) - ctx.loop = event_loop + ctx.loop = asyncio.get_running_loop() ctx.fdsync = CoroutineMock(return_value=None) ctx.write = CoroutineMock(side_effect=asyncio.InvalidStateError) @@ -415,9 +415,9 @@ async def test_partial_writes(temp_file, event_loop): ] -async def test_write_returned_negative(temp_file, event_loop): +async def test_write_returned_negative(temp_file): ctx = Mock(caio.AbstractContext) - ctx.loop = event_loop + ctx.loop = asyncio.get_running_loop() ctx.fdsync = CoroutineMock(return_value=None) ctx.write = CoroutineMock(side_effect=asyncio.InvalidStateError) @@ -437,9 +437,9 @@ async def test_write_returned_negative(temp_file, event_loop): assert raises.value.filename == temp_file -async def test_write_returned_zero(temp_file, event_loop): +async def test_write_returned_zero(temp_file): ctx = Mock(caio.AbstractContext) - ctx.loop = event_loop + ctx.loop = asyncio.get_running_loop() ctx.fdsync = CoroutineMock(return_value=None) ctx.write = CoroutineMock(side_effect=asyncio.InvalidStateError) -- 2.54.0