Skip to content

Commit

Permalink
chore: replace even_loop fixture (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
Olegt0rr committed Jan 12, 2024
1 parent 4ad2c58 commit 7090590
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
5 changes: 3 additions & 2 deletions aresponses/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ def history(self) -> List[RoutingLog]:


@asyncio_fixture()
async def aresponses(event_loop) -> ResponsesMockServer:
async with ResponsesMockServer(loop=event_loop) as server:
async def aresponses() -> ResponsesMockServer:
loop = asyncio.get_running_loop()
async with ResponsesMockServer(loop=loop) as server:
yield server
11 changes: 7 additions & 4 deletions tests/test_server.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import asyncio
import re

import aiohttp
Expand Down Expand Up @@ -110,8 +111,9 @@ async def test_https(aresponses):


@pytest.mark.asyncio
async def test_context_manager(event_loop):
async with aresponses_mod.ResponsesMockServer(loop=event_loop) as arsps:
async def test_context_manager():
loop = asyncio.get_running_loop()
async with aresponses_mod.ResponsesMockServer(loop=loop) as arsps:
arsps.add("foo.com", "/", "get", aresponses_mod.Response(text="hi"))

url = "http://foo.com"
Expand Down Expand Up @@ -411,9 +413,10 @@ def _short_recursion_limit():

@pytest.mark.asyncio
@pytest.mark.usefixtures("_short_recursion_limit")
async def test_not_exceeding_recursion_limit(event_loop):
async def test_not_exceeding_recursion_limit():
loop = asyncio.get_running_loop()
for _ in range(sys.getrecursionlimit()):
async with aresponses_mod.ResponsesMockServer(loop=event_loop) as arsps:
async with aresponses_mod.ResponsesMockServer(loop=loop) as arsps:
arsps.add("fake-host", "/", "get", "hello")
async with aiohttp.ClientSession() as session:
async with session.get("http://fake-host"):
Expand Down

0 comments on commit 7090590

Please sign in to comment.