Injabie3/lui-cogs-v3

[CI] Cog Unit Tests are consistently failing

quachtridat opened this issue · 0 comments

Summary

CI has been consistently failing recently with log lines like

AttributeError: 'async_generator' object has no attribute 'foo'

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 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).

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:

  • Use pytest_asyncio.fixture() instead of pytest.fixture(), or
  • Have a pytest config file (e.g., pytest.ini) and set async_mode to auto.

The former is preferred simply because we don't need an additional file to tweak this behavior of pytest-asyncio.