Skip to content

Commit 46ddb29

Browse files
committed
fix(test): use function scope for asyncio test loop
We were configuring a module-level loop, but had @pytest_asyncio.fixture without a scope, with the intention of being function scope. This is now triggers an error with pytest-asyncio. Following advice of https://pytest-asyncio.readthedocs.io/en/stable/how-to-guides/migrate_from_0_23.html we now explicitly set the asyncio_default_fixture_loop_scope pytest option to "function".
1 parent a5a3eb7 commit 46ddb29

File tree

4 files changed

+4
-3
lines changed

4 files changed

+4
-3
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,4 @@ convention = "numpy"
9999

100100
[tool.pytest.ini_options]
101101
addopts = ["--doctest-modules"]
102+
asyncio_default_fixture_loop_scope = "function"

test/test_auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
TestClient: TypeAlias = _TestClient[web.Request, web.Application]
3535

36-
pytest_mark_asyncio = pytest.mark.asyncio(loop_scope="module")
36+
pytest_mark_asyncio = pytest.mark.asyncio()
3737

3838

3939
@pytest.fixture

test/test_datapath.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464

6565
TestClient: TypeAlias = _TestClient[web.Request, web.Application]
6666

67-
pytest_mark_asyncio = pytest.mark.asyncio(loop_scope="module")
67+
pytest_mark_asyncio = pytest.mark.asyncio()
6868

6969

7070
@pytest.fixture

test/test_kv.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383

8484
from typing_extensions import TypeAlias
8585

86-
pytest_mark_asyncio = pytest.mark.asyncio(loop_scope="module")
86+
pytest_mark_asyncio = pytest.mark.asyncio()
8787

8888

8989
@given(v=st.integers(min_value=0, max_value=2**80 - 1))

0 commit comments

Comments
 (0)