pytest-dev / pytest-asyncio

Asyncio support for pytest
https://pytest-asyncio.readthedocs.io
Apache License 2.0
1.43k stars 151 forks source link

Concurrent async fixture setup / teardown #118

Open dimaqq opened 5 years ago

dimaqq commented 5 years ago

This is more an idea / question how hard it would be.

While pytest ensures stable fixture order, it's made with synchronous fixtures in mind.

pytest-asyncio on the other hand allows for async fixtures and typically async test cases imply async code under test which implies async dependencies which imply async fixtures.

Thus, how about running setup and teardown asynchronously too, for example:

@pytest.fixture
async def A():
    ...
    yield
    ...

@pytest.fixture
async def B(A):
    ...
    yield
    ...

@pytest.fixture
async def C(A):
    ...
    yield
    ...

@pytest.fixture
async def D(B, C):
    ...
    yield
    ...

Would run as:

seifertm commented 2 years ago

@dimaqq I know this issue is specifically about the fixture setup. #69 is about running tests asynchronously.

Would it be acceptable for you to close this issue in favour of #69?

dimaqq commented 2 years ago

I think you can decide that @seifertm