delfick / alt-pytest-asyncio

An alternative plugin for pytest to make it support async tests and fixtures
https://alt-pytest-asyncio.readthedocs.io
MIT License
27 stars 5 forks source link

Using pytest markers to associate timeouts with fixtures is not officially supported by pytest. #19

Closed pokowaka closed 1 week ago

pokowaka commented 4 weeks ago

Our tests rely on configuring fixture timeouts through markers. This currently causes warnings in pytest 8.3.3, and will likely break in future versions when the warning becomes an error.

See the example test below:

import pytest
import asyncio

@pytest.fixture()
@pytest.mark.async_timeout(0.1)
async def my_amazing_fixture():
    try:
        await asyncio.sleep(1)
        yield 1
    finally:
        await asyncio.sleep(1)

async def test_my_amazing_fixture(my_amazing_fixture):
    assert True

See also https://github.com/pytest-dev/pytest/issues/12850

delfick commented 2 weeks ago

@pokowaka can you give https://github.com/delfick/alt-pytest-asyncio/pull/20 a go and tell me if there's anything about this that makes your life difficult?

delfick commented 1 week ago

@pokowaka I've released the change in 0.9.0. Please don't hesitate to reopen this issue if you want to when you get around to giving it a go!