diff --git a/pyproject.toml b/pyproject.toml index c5c7ba2..cad4286 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -84,6 +84,7 @@ addopts = """ --color=yes """ # filterwarnings=error +asyncio_default_fixture_loop_scope = "function" [tool.mypy] ignore_missing_imports = true diff --git a/tests/conftest.py b/tests/conftest.py index c97630f..6970717 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -59,12 +59,12 @@ else: @pytest_asyncio.fixture -async def aio_session(event_loop): +async def aio_session(): async with aiohttp.ClientSession() as session: yield session @pytest_asyncio.fixture -async def aio_connector(event_loop): +async def aio_connector(): async with aiohttp.TCPConnector(limit_per_host=16) as conn: yield conn diff --git a/tests/unit/test_metasync.py b/tests/unit/test_metasync.py index e099db1..ba17dd2 100644 --- a/tests/unit/test_metasync.py +++ b/tests/unit/test_metasync.py @@ -1,5 +1,7 @@ from __future__ import annotations +import asyncio + import hypothesis.strategies as st import pytest import pytest_asyncio @@ -56,23 +58,19 @@ async def test_basic(monkeypatch): @pytest_asyncio.fixture -@pytest.mark.asyncio -async def conflict_state(request, event_loop): +async def conflict_state(request): a = MemoryStorage() b = MemoryStorage() status = {} await a.set_meta("foo", "bar") await b.set_meta("foo", "baz") - def cleanup(): - async def do_cleanup(): - assert await a.get_meta("foo") == "bar" - assert await b.get_meta("foo") == "baz" - assert not status + async def do_cleanup(): + assert await a.get_meta("foo") == "bar" + assert await b.get_meta("foo") == "baz" + assert not status - event_loop.run_until_complete(do_cleanup()) - - request.addfinalizer(cleanup) + request.addfinalizer(lambda: asyncio.run(do_cleanup())) return a, b, status