You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use pytest and pytest-asyncio to test a few Tornado applications. I had some trouble (see tornadoweb/tornado#2324) with Tornado getting a different event loop from the one created by pytest-asyncio's event_loop fixture.
This can be fixed by overriding Tornado's default testing behavior to use the "current" loop, rather than creating a new one. The issue is that pytest-asyncio does not call asyncio.set_event_loop with the loop it creates in the event_loop fixture – without which, there is no "current" loop.
I'd like to propose change the event_loop fixture to look like this:
Hm, I think it used to be considered bad form to call asyncio.get_event_loop before, but now it's considered OK, so we might enable this. @asvetlov thoughts?
In any case, we use a fixture hook to do things like this in order to keep the event_loop fixture very simple, so it's simple to override.
pytest-asyncio operates with async tests only.
The async test always have an event loop available by both asyncio.get_event_loop() and asyncio.get_running_loop() calls.
There is no need to explicitly call asyncio.set_event_loop(), it is done by loop.run_untile_complete() already.
I use pytest and pytest-asyncio to test a few Tornado applications. I had some trouble (see tornadoweb/tornado#2324) with Tornado getting a different event loop from the one created by pytest-asyncio's
event_loop
fixture.This can be fixed by overriding Tornado's default testing behavior to use the "current" loop, rather than creating a new one. The issue is that pytest-asyncio does not call
asyncio.set_event_loop
with the loop it creates in theevent_loop
fixture – without which, there is no "current" loop.I'd like to propose change the
event_loop
fixture to look like this:How does that sound? I'm happy to submit a PR, but I wanted to get feedback on the idea first.
The text was updated successfully, but these errors were encountered: