Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions test/asynchronous/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,15 @@
from test import pytest_conf
from test.asynchronous import async_setup, async_teardown

import pytest
import pytest_asyncio

_IS_SYNC = False


@pytest.fixture(scope="session")
def event_loop_policy():
# The default asyncio loop implementation on Windows
# has issues with sharing sockets across loops (https://github.com/python/cpython/issues/122240)
# We explicitly use a different loop implementation here to prevent that issue
if sys.platform == "win32":
return asyncio.WindowsSelectorEventLoopPolicy() # type: ignore[attr-defined]

return asyncio.get_event_loop_policy()
# The default asyncio loop implementation on Windows has issues with sharing
# sockets across loops (https://github.com/python/cpython/issues/122240).
# We explicitly use a different loop implementation here to prevent that issue
if sys.platform == "win32":
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) # type: ignore[attr-defined]


@pytest_asyncio.fixture(scope="package", autouse=True)
Expand Down
15 changes: 5 additions & 10 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,11 @@

_IS_SYNC = True


@pytest.fixture(scope="session")
def event_loop_policy():
# The default asyncio loop implementation on Windows
# has issues with sharing sockets across loops (https://github.com/python/cpython/issues/122240)
# We explicitly use a different loop implementation here to prevent that issue
if sys.platform == "win32":
return asyncio.WindowsSelectorEventLoopPolicy() # type: ignore[attr-defined]

return asyncio.get_event_loop_policy()
# The default asyncio loop implementation on Windows has issues with sharing
# sockets across loops (https://github.com/python/cpython/issues/122240).
# We explicitly use a different loop implementation here to prevent that issue
if sys.platform == "win32":
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) # type: ignore[attr-defined]


@pytest.fixture(scope="package", autouse=True)
Expand Down
Loading