moe-serifu-circle / moe-serifu-agent

Anime-themed personal assistant and goal-oriented intelligent agent

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Prevent asyncio from ignoring exceptions in unit tests

jghibiki opened this issue · comments

In some unit tests where the mock is improperly configured, the loop is being closed before all tasks have shutdown properly resulting in an exception which asyncio handles and ignores to prevent the event loop from breaking.

Design Details

Find a way to prevent asyncio from squashing this exception message wrongfully as we want it to cause a unit test failure if it happens.

Done When

Ignored exceptions are no longer ignored and are able to fail the unit tests.

Quote from python Unit Test docs

By default this runner shows DeprecationWarning, PendingDeprecationWarning, ResourceWarning and ImportWarning even if they are ignored by default. Deprecation warnings caused by deprecated unittest methods are also special-cased and, when the warning filters are 'default' or 'always', they will appear only once per-module, in order to avoid too many warning messages. This behavior can be overridden using Python’s -Wd or -Wa options (see Warning control) and leaving warnings to None.

Example Warning:
/usr/lib64/python3.7/asyncio/base_events.py:607: ResourceWarning: unclosed event loop <_UnixSelectorEventLoop running=False closed=False debug=False> source=self)

This is one of the specified warnings, and it appears to be normal and accepted that ResourceWarnings not be elevated.

After discussion with @jghibiki we have decided to close this, as it is not causing unit tests to detect false positives or false negatives. Invalidation of unit tests is the primary concern, and that does not appear to be happening. I'd say let's just keep an eye out for that in the future, just in case, but for now I think we're good