When the strict mode is on, async fixtures need to be defined with decorator @pytest_asyncio.fixture() to be picked up by pytest-asyncio (and function correctly in our cases). Fixtures decorated with @pytest.fixture() will not be recognized.
For SFUAnime/Ren, this line of code tweaks pytest-asyncio's test discovery mode by making in auto instead of strict (the default value), and thus async fixtures decorated with @pytest.fixture() continue to work normally. This is not the case with the current repo (Injabie3/lui-cogs-v3).
Summary
CI has been consistently failing recently with log lines like
Failed runs
Root cause
This is caused by
pytest-asyncio
's strict test discovery mode.When the strict mode is on, async fixtures need to be defined with decorator
@pytest_asyncio.fixture()
to be picked up bypytest-asyncio
(and function correctly in our cases). Fixtures decorated with@pytest.fixture()
will not be recognized.For SFUAnime/Ren, this line of code tweaks
pytest-asyncio
's test discovery mode by making inauto
instead ofstrict
(the default value), and thus async fixtures decorated with@pytest.fixture()
continue to work normally. This is not the case with the current repo (Injabie3/lui-cogs-v3).How it was found out
There is a difference in the
asyncio
mode between this workflow log line from an unsuccessful run in Injabie3/lui-cogs-v3 and this workflow log line from a successful run in SFUAnime/Ren.Proposed fix
To resolve, we need to:
pytest_asyncio.fixture()
instead ofpytest.fixture()
, orpytest.ini
) and setasync_mode
toauto
.The former is preferred simply because we don't need an additional file to tweak this behavior of
pytest-asyncio
.