From: Colin Watson <cjwatson@debian.org>
Date: Mon, 15 Sep 2025 00:58:14 +0100
Subject: Replace remaining uses of event_loop fixture

The test suite started failing with pytest-asyncio >= 1.0.0, as that
version removed the deprecated `event_loop` fixture.  Finish the work of
replacing it that was started in
https://github.com/aresponses/aresponses/pull/76.

Forwarded: https://github.com/aresponses/aresponses/pull/85
Last-Update: 2025-09-15
---
 README.md                         | 19 ++++++++++++-------
 tests/test_with_aiohttp_client.py | 11 +++++++----
 2 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/README.md b/README.md
index 7ae2ad5..9cf33fd 100644
--- a/README.md
+++ b/README.md
@@ -179,18 +179,21 @@ async def test_history(aresponses):
 
 #### Context manager usage
 ```python
+import asyncio
+
 import aiohttp
 import pytest
 import aresponses
 
 
 @pytest.mark.asyncio
-async def test_foo(event_loop):
-    async with aresponses.ResponsesMockServer(loop=event_loop) as arsps:
+async def test_foo():
+    loop = asyncio.get_running_loop()
+    async with aresponses.ResponsesMockServer(loop=loop) as arsps:
         arsps.add('foo.com', '/', 'get', 'hi there!!')
         arsps.add(arsps.ANY, '/', 'get', arsps.Response(text='hey!'))
         
-        async with aiohttp.ClientSession(loop=event_loop) as session:
+        async with aiohttp.ClientSession(loop=loop) as session:
             async with session.get('http://foo.com') as response:
                 text = await response.text()
                 assert text == 'hi'
@@ -216,10 +219,12 @@ async def aresponses(loop):
 If you're trying to use the `aiohttp_client` test fixture then you'll need to mock out the aiohttp `loop` fixture
 instead:
 ```python
-@pytest.fixture
-def loop(event_loop):
-    """replace aiohttp loop fixture with pytest-asyncio fixture"""
-    return event_loop
+import pytest_asyncio
+
+@pytest_asyncio.fixture
+async def loop():
+    """Replace aiohttp loop fixture."""
+    return asyncio.get_running_loop()
 ```
 
 ## Contributing
diff --git a/tests/test_with_aiohttp_client.py b/tests/test_with_aiohttp_client.py
index b7b0847..064d6fc 100644
--- a/tests/test_with_aiohttp_client.py
+++ b/tests/test_with_aiohttp_client.py
@@ -1,12 +1,15 @@
+import asyncio
+
 import aiohttp
 import pytest
+import pytest_asyncio
 from aiohttp import web
 
 
-@pytest.fixture()
-def loop(event_loop):
-    """replace aiohttp loop fixture with pytest-asyncio fixture"""
-    return event_loop
+@pytest_asyncio.fixture()
+async def loop():
+    """Replace aiohttp loop fixture."""
+    return asyncio.get_running_loop()
 
 
 def make_app():
