Injabie3 / lui-cogs-v3

Cogs for Red-DiscordBot (v3), used by the SFU Anime Club. Branches for dpy1 and dpy2. See Injabie3/lui-cogs for Redv2/dpy0 cogs.
14 stars 7 forks source link

[CI] Cog Unit Tests are consistently failing #10

Closed quachtridat closed 1 year ago

quachtridat commented 1 year ago

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:

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