From 895ae205caf06cc066d40c93b4386252d97fd414 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Fri, 15 Dec 2023 11:39:51 +0000 Subject: [PATCH] use asyncio.run to run coroutines --- tests/integration/test_aiohttp.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/integration/test_aiohttp.py b/tests/integration/test_aiohttp.py index a740ef2..0af2d49 100644 --- a/tests/integration/test_aiohttp.py +++ b/tests/integration/test_aiohttp.py @@ -14,10 +14,10 @@ from .aiohttp_utils import aiohttp_app, aiohttp_request # noqa: E402 def run_in_loop(fn): - with contextlib.closing(asyncio.new_event_loop()) as loop: - asyncio.set_event_loop(loop) - task = loop.create_task(fn(loop)) - return loop.run_until_complete(task) + async def wrapper(): + return await fn(asyncio.get_running_loop()) + + return asyncio.run(wrapper()) def request(method, url, output="text", **kwargs):