| 1 |
From 478fdba1b298abe9cb4c581514ca328f13727faf Mon Sep 17 00:00:00 2001 |
| 2 |
From: Yuri Konotopov <[email protected]> |
| 3 |
Date: Sun, 23 Aug 2026 13:07:12 +0400 |
| 4 |
Subject: [PATCH] tests: do not use event_loop fixture |
| 5 |
|
| 6 |
It was removed from latest version of pytest-asyncio |
| 7 |
|
| 8 |
Signed-off-by: Yuri Konotopov <[email protected]> |
| 9 |
|
| 10 |
Forwarded: https://github.com/mosquito/aiofile/pull/113 |
| 11 |
Applied-Upstream: https://github.com/mosquito/aiofile/commit/04f06a095733e424bad71ecc45b13a2d4eb4f1f2 |
| 12 |
--- |
| 13 |
tests/conftest.py | 7 +++++-- |
| 14 |
tests/test_aio.py | 12 ++++++------ |
| 15 |
2 files changed, 11 insertions(+), 8 deletions(-) |
| 16 |
|
| 17 |
diff --git a/tests/conftest.py b/tests/conftest.py |
| 18 |
index 00a75e5..8cb68c1 100644 |
| 19 |
--- a/tests/conftest.py |
| 20 |
+++ b/tests/conftest.py |
| 21 |
@@ -1,3 +1,4 @@ |
| 22 |
+import asyncio |
| 23 |
from functools import partial |
| 24 |
from types import ModuleType |
| 25 |
from typing import List, Union |
| 26 |
@@ -46,12 +47,14 @@ IMPLEMENTATION_NAMES: List[str] = list( |
| 27 |
|
| 28 |
|
| 29 |
@pytest.fixture(params=IMPLEMENTATIONS, ids=IMPLEMENTATION_NAMES) |
| 30 |
-async def aio_context(request, event_loop): |
| 31 |
+async def aio_context(request): |
| 32 |
if request.param is None: |
| 33 |
yield None |
| 34 |
return |
| 35 |
|
| 36 |
- async with request.param.AsyncioContext(loop=event_loop) as context: |
| 37 |
+ async with request.param.AsyncioContext( |
| 38 |
+ loop=asyncio.get_event_loop() |
| 39 |
+ ) as context: |
| 40 |
yield context |
| 41 |
|
| 42 |
|
| 43 |
diff --git a/tests/test_aio.py b/tests/test_aio.py |
| 44 |
index e467145..60f9caa 100644 |
| 45 |
--- a/tests/test_aio.py |
| 46 |
+++ b/tests/test_aio.py |
| 47 |
@@ -387,9 +387,9 @@ async def test_write_read_nothing(aio_file_maker, temp_file, mode, data): |
| 48 |
assert await afp.read() == data |
| 49 |
|
| 50 |
|
| 51 |
-async def test_partial_writes(temp_file, event_loop): |
| 52 |
+async def test_partial_writes(temp_file): |
| 53 |
ctx = Mock(caio.AbstractContext) |
| 54 |
- ctx.loop = event_loop |
| 55 |
+ ctx.loop = asyncio.get_running_loop() |
| 56 |
ctx.fdsync = CoroutineMock(return_value=None) |
| 57 |
ctx.write = CoroutineMock(side_effect=asyncio.InvalidStateError) |
| 58 |
|
| 59 |
@@ -415,9 +415,9 @@ async def test_partial_writes(temp_file, event_loop): |
| 60 |
] |
| 61 |
|
| 62 |
|
| 63 |
-async def test_write_returned_negative(temp_file, event_loop): |
| 64 |
+async def test_write_returned_negative(temp_file): |
| 65 |
ctx = Mock(caio.AbstractContext) |
| 66 |
- ctx.loop = event_loop |
| 67 |
+ ctx.loop = asyncio.get_running_loop() |
| 68 |
ctx.fdsync = CoroutineMock(return_value=None) |
| 69 |
ctx.write = CoroutineMock(side_effect=asyncio.InvalidStateError) |
| 70 |
|
| 71 |
@@ -437,9 +437,9 @@ async def test_write_returned_negative(temp_file, event_loop): |
| 72 |
assert raises.value.filename == temp_file |
| 73 |
|
| 74 |
|
| 75 |
-async def test_write_returned_zero(temp_file, event_loop): |
| 76 |
+async def test_write_returned_zero(temp_file): |
| 77 |
ctx = Mock(caio.AbstractContext) |
| 78 |
- ctx.loop = event_loop |
| 79 |
+ ctx.loop = asyncio.get_running_loop() |
| 80 |
ctx.fdsync = CoroutineMock(return_value=None) |
| 81 |
ctx.write = CoroutineMock(side_effect=asyncio.InvalidStateError) |
| 82 |
|
| 83 |
-- |
| 84 |
2.54.0 |
| 85 |
|