Closed
Description
Consider this:
import pytest
async def foo():
print("foo")
@pytest.yield_fixture
def my_fixture(event_loop):
print(event_loop.is_closed()) # "False"
event_loop.run_until_complete(foo()) # "foo"
yield None
print(event_loop.is_closed()) # "True"... noooo!
event_loop.run_until_complete(foo()) # goes boom
@pytest.mark.asyncio
async def test_foo(my_fixture):
await foo()
Run this code with py.test -s <file>
and you'll see the output as indicated by the comments in the code.
The event loop is closed before my finalizer code can run. This is also the case when I write my fixture without a yield, instead adding a finalizer function.
This is weird. I'm pretty sure that this worked just fine a couple of months ago.
Metadata
Metadata
Assignees
Labels
No labels