Skip to content

Latest commit

 

History

History
41 lines (26 loc) · 1.02 KB

README.md

File metadata and controls

41 lines (26 loc) · 1.02 KB

Event loop is closed when using pytester and async fixture finalization

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.

Steps to reproduce the bug

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.

Workaround #1

Prior pytest-asyncio<0.17 you could redefine the event_loop fixture without closing the loop on finalization.

tox -e py3-workaround_1

Workaround #2

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