Closed dariofaccin closed 6 months ago
Happening to me as well. Reverting to 8.1.2 fixed it.
Which version of pytest-asyncio are you using?
Noddy case:
import pytest
@pytest.fixture
async def myfixture():
yield 1
def test_noddy(myfixture):
assert 1 == myfixture
I think this issue may have been introduced at #12096
This issue was already fixed in the latest version of pytest-asyncio, if you can please upgrade. If you're still on pytest-asyncio 0.21, a user made a proposal for a backport https://github.com/pytest-dev/pytest-asyncio/pull/823 but I can't tell if it will be merged.
This issue was already fixed in the latest version of pytest-asyncio, if you can please upgrade
Anything else actionable by pytest, given this is fixed by pytest-asyncio?
This issue was already fixed in the latest version of pytest-asyncio, if you can please upgrade. If you're still on pytest-asyncio 0.21, a user made a proposal for a backport pytest-dev/pytest-asyncio#823 but I can't tell if it will be merged.
Unfortunately we can't use 0.23 yet.
This issue was already fixed in the latest version of pytest-asyncio, if you can please upgrade
I can't upgrade (and it seems like I'm not the only one) higher than v21 because of a known issue with v23 that is still being fixed:
As of v0.23, pytest-asyncio attaches an asyncio event loop to each item of the test suite (i.e. session, packages, modules, classes, functions) and allows tests to be run in those loops when marked accordingly. Pytest-asyncio currently assumes that async fixture scope is correlated with the new event loop scope. This prevents fixtures from being evaluated independently from the event loop scope and breaks some existing test suites (see #706). For example, a test suite may require all fixtures and tests to run in the same event loop, but have async fixtures that are set up and torn down for each module. If you’re affected by this issue, please continue using the v0.21 release, until it is resolved.
https://pytest-asyncio.readthedocs.io/en/latest/reference/changelog.html
0.21.2 has been released and it works with pytest 8.2.0
The issue is resolved, I will edit the top post with information and pin for visibility for a few days.
Maintainer note: To fix compatibility with pytest>=8.2.0, update pytest-asyncio to >=0.23.6, or >=v0.21.2 if you're on 0.21.x.
After upgrading from pytest 8.1.2 to pytest 8.2.0 I am getting the following error during tests setup:
Python version (if relevant): 3.11.6