Repository navigation
Closed
Description
When pytest-9.2.0 is used with pytest-asyncio, -Werror and an empty directory temp:
- It generates deprecation warnings.
- The exit code is 3 "Internal error happened while executing tests", when it should be 5 "No tests were collected".
I guess this could mean that pytest-asyncio needs to be updated to match pytest-9.2.0?
To reproduce:
> pip install pytest pytest-asyncio
...
Successfully installed pytest-9.2.0 pytest-asyncio-1.4.1
> pytest -Werror temp
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File ".../lib/python3.14/site-packages/_pytest/main.py", line 329, in wrap_session
INTERNALERROR> config._do_configure()
INTERNALERROR> ~~~~~~~~~~~~~~~~~~~~^^
INTERNALERROR> File ".../lib/python3.14/site-packages/_pytest/config/__init__.py", line 1370, in _do_configure
INTERNALERROR> self.hook.pytest_configure.call_historic(kwargs=dict(config=self))
INTERNALERROR> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> File ".../lib/python3.14/site-packages/pluggy/_caller.py", line 222, in call_historic
INTERNALERROR> res = self._hookexec(self.name, self._hookimpls.copy(), kwargs, False)
INTERNALERROR> File ".../lib/python3.14/site-packages/pluggy/_manager.py", line 183, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR> ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> File ".../lib/python3.14/site-packages/pluggy/_execution.py", line 195, in _multicall
INTERNALERROR> raise exception
INTERNALERROR> File ".../lib/python3.14/site-packages/pluggy/_execution.py", line 147, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File ".../lib/python3.14/site-packages/pytest_asyncio/plugin.py", line 299, in pytest_configure
INTERNALERROR> warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET))
INTERNALERROR> ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> pytest.PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset.
INTERNALERROR> 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"
> echo $?
3
>
Without pytest-asyncio, pytest-9.2.0 behaves as expected:
> pip uninstall pytest-asyncio
...
Successfully uninstalled pytest-asyncio-1.4.1
> pytest -Werror temp
======================================================================== test session starts ========================================================================
platform linux -- Python 3.14.8, pytest-9.2.0, pluggy-1.7.0
rootdir: ...
collected 0 items
======================================================================= no tests ran in 0.71s =======================================================================
> echo $?
5
>
Similarly with previous release pytest-9.1.1 and pytest-asyncio:
> pip install pytest==9.1.1 pytest-asyncio
...
Successfully installed pytest-9.1.1 pytest-asyncio-1.4.1
> pytest -Werror temp
==================================================================================================== test session starts ====================================================================================================
platform linux -- Python 3.14.8, pytest-9.1.1, pluggy-1.7.0
rootdir: ...
plugins: platformdirs-4.13.5, asyncio-1.4.0, anyio-4.15.1
asyncio: mode=Mode.STRICT, debug=False, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function
collected 0 items
=================================================================================================== no tests ran in 0.76s ===================================================================================================
> echo $?
5
>
Installed packages:
> pip list
iniconfig 2.3.1
packaging 26.3
pip 26.0.1
pluggy 1.7.0
Pygments 2.21.0
pytest 9.2.0
pytest-asyncio 1.4.1
>
Operating system versions
> uname -a
Linux ... 6.19.13+deb14-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.19.13-1 (2026-04-18) x86_64 GNU/Linux
>
Metadata
Metadata
Assignees
Labels
No labels
Activity
bluetech commentedon Oct 28, 2026
Yes, this is do to this change (note from the changelog):
It does seem a bit unfortunate that a plain pytest + pytest-asyncio now "crashes" with
-Werror, however-Werroris kind of requesting this behavior.I'm not sure there's much we can do here. I suggest setting
asyncio_default_fixture_loop_scopein your configuration which will resolve the deprecation.julian-smith-artifex-com commentedon Oct 28, 2026
@bluetech Many thanks for the swift response.
pytest -o asyncio_default_fixture_loop_scope=functionavoids the problem for me.