Skip to content

Commit

Permalink
Configure asyncio_default_fixture_loop_scope
Browse files Browse the repository at this point in the history
This resolves:

    PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset.
    The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session"

See https://pytest-asyncio.readthedocs.io/en/latest/reference/configuration.html#asyncio-default-fixture-loop-scope

Accordingly, we need to update pytest_asyncio.fixture following
https://pytest-asyncio.readthedocs.io/en/latest/how-to-guides/migrate_from_0_23.html.
  • Loading branch information
dlax committed Nov 19, 2024
1 parent 4bd93f3 commit c59ebcc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[pytest]
addopts = -vvv --strict-markers --showlocals --doctest-modules --ignore pgtoolkit/ctl.py
asyncio_mode = strict
asyncio_default_fixture_loop_scope = function
filterwarnings =
error
4 changes: 2 additions & 2 deletions tests/test_ctl_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def pgctl() -> ctl.PGCtl:
pytest.skip(str(e))


@pytest_asyncio.fixture(scope="module")
@pytest_asyncio.fixture(loop_scope="module")
async def apgctl() -> ctl.AsyncPGCtl:
try:
return await ctl.AsyncPGCtl.get()
Expand Down Expand Up @@ -51,7 +51,7 @@ def initdb(tmp_path_factory, pgctl: ctl.PGCtl) -> tuple[Path, Path, Path]:
return datadir, waldir, pid_path


@pytest_asyncio.fixture(scope="module")
@pytest_asyncio.fixture(loop_scope="module")
async def ainitdb(tmp_path_factory, apgctl: ctl.AsyncPGCtl) -> tuple[Path, Path, Path]:
datadir = tmp_path_factory.mktemp("data")
waldir = tmp_path_factory.mktemp("wal")
Expand Down

0 comments on commit c59ebcc

Please sign in to comment.