mongo-python-driver/test/conftest.py
Noah Stapp 0e8d70457f
Async client uses tasks instead of threads
PYTHON-4725 - Async client should use tasks for SDAM instead of threads
PYTHON-4860 - Async client should use asyncio.Lock and asyncio.Condition
PYTHON-4941 - Synchronous unified test runner being used in asynchronous tests
PYTHON-4843 - Async test suite should use a single event loop
PYTHON-4945 - Fix test cleanups for mongoses

Co-authored-by: Iris <58442094+sleepyStick@users.noreply.github.com>
2024-11-26 16:55:27 -05:00

31 lines
796 B
Python

from __future__ import annotations
import asyncio
import sys
from test import pytest_conf, setup, teardown
import pytest
_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()
@pytest.fixture(scope="package", autouse=True)
def test_setup_and_teardown():
setup()
yield
teardown()
pytest_collection_modifyitems = pytest_conf.pytest_collection_modifyitems