Closed as not planned
Closed as not planned
Description
It appears that the pytest-asyncio 0.23 broke class-scoped fixtures defined outside of the class. Namely, I used to have the following setup:
conftest.py:
@pytest_asyncio.fixture(scope="class")
async def run_important_program_in_class() -> AsyncGenerator[ImportantProgram, None]:
"""runs one Program instance per test class"""
async with run_important_program(cfg=generate_cfg()) as p:
yield p
and then the test classes used
@pytest.mark.usefixtures("run_important_program_in_class")
however with upgrade to 0.23, now the following error being reported:
ERROR my_example_test.py - _pytest.config.exceptions.UsageError: my_example_test.py is marked to be run i
n an event loop with scope class, but is not part of any class
The error disappears of the fixture is moved to the class definition, like this:
Class TestSomeStuff:
@pytest_asyncio.fixture(scope="class")
async def run_important_program_in_class() -> AsyncGenerator[ImportantProgram, None]:
async with run_important_program(cfg=generate_cfg()) as p:
yield p
But this approach leads to significant code duplication