Closed
Description
When defining a custom loop policy in a fixture, the first test is executed with the loop from the default event loop policy and not from the custom loop policy. I assume pytest-asyncio creates the first event loop before the fixture for the custom loop policy has run.
Simple reproduction test (Windows):
import asyncio
import pytest
@pytest.fixture(autouse=True, scope="module")
def set_loop_policy():
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
@pytest.mark.asyncio
async def test_loop(event_loop):
assert isinstance(event_loop, asyncio.SelectorEventLoop)
@pytest.mark.asyncio
async def test_loop_second(event_loop):
assert isinstance(event_loop, asyncio.SelectorEventLoop)
The first test fails, the second passes. I would expect that both tests pass.