Skip to content

Commit

Permalink
Silence Pytest deprecation warning about async fixture loop
Browse files Browse the repository at this point in the history
With Pytest version 8.3.3 and pytest-asyncio 0.24.0 in Python 3.10
(and possibly other versions), we get this deprecation warning when
running `check/pytest`:

```
[...]/python3.10/site-packages/pytest_asyncio/plugin.py:208:
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"
```

This warning is essentially useless for our purposes, and only causes
unnecessary confusion about what's going on. Based on the discussion
at <pytest-dev/pytest-asyncio#924>, a simple
way to silence the deprecation warning is to add an option to
`pyproject.toml`.
  • Loading branch information
mhucka committed Sep 15, 2024
1 parent d85d92b commit 37899df
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ markers = [
"slow: slow tests that should be skipped by default.",
"weekly: tests to be run only by weekly CI automation.",
]
# Silence deprecation warnings about option "asyncio_default_fixture_loop_scope"
asyncio_default_fixture_loop_scope = "function"

0 comments on commit 37899df

Please sign in to comment.