This repo contains a minimal reproducible example of a bug with an async
autouse=True
fixture finalization when using pytester
plugin.
Basically, this async fixture added as a finalizer to a non-async test.
The bug only appears when using pytester.
To reproduce a bug as is:
tox -e py3-bug
Actual result:
ERROR tests/test_fixtures.py::test_fixture_setup - RuntimeError: Event loop is closed
Expected result: no error at all, finalizer should not run in the regular test.
Prior pytest-asyncio<0.17
you could redefine the event_loop
fixture without
closing the loop on finalization.
tox -e py3-workaround_1
In the pytest-asyncio>=0.17
the workaround #1 no longer works. However,
you can redefine the fixture with async finalization
tox -e py3-workaround_2