Skip to content

Commit 07750b3

Browse files
chore: update pytest-asyncio uvloop configuration (#251)
# Summary Update the test suite’s uvloop integration to align with `pytest-asyncio`’s loop-factory direction ahead of Python 3.14 policy deprecations. The shared pytest configuration now uses the hook-based uvloop setup only, matching the repository’s `pytest-asyncio>=1.0,<2` requirement. # Changes - **pytest-asyncio loop factory hook** - Keep `pytest_asyncio_loop_factories(...)` in `/home/runner/work/plugboard/plugboard/tests/conftest.py` - Configure uvloop via `uvloop.new_event_loop` - **Remove obsolete compatibility fallback** - Drop the conditional `event_loop_policy` fallback for older `pytest-asyncio` releases - Simplify the hook implementation now that the project locks to `pytest-asyncio 1.x` - **Focused coverage** - Keep `/home/runner/work/plugboard/plugboard/tests/unit/test_conftest.py` - Update it to validate only the supported hook-based uvloop configuration path - **Branch maintenance** - Merge `origin/main` into this branch and resolve the resulting conflict in `/home/runner/work/plugboard/plugboard/tests/conftest.py` - **Validation** - Ran `make lint` - Ran `make build` - Ran `uv run pytest -rs tests/unit/test_conftest.py tests/integration/test_component_event_handlers.py` --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: toby-coleman <13170610+toby-coleman@users.noreply.github.com>
1 parent 71d67b8 commit 07750b3

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

tests/conftest.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Configuration for the test suite."""
22

33
from abc import ABC
4+
import asyncio
45
import multiprocessing
56
import os
67
import typing as _t
@@ -20,10 +21,10 @@
2021
from plugboard.utils.settings import Settings
2122

2223

23-
@pytest.fixture(scope="session")
24-
def event_loop_policy() -> uvloop.EventLoopPolicy:
25-
"""Set uvloop as the event loop policy for the test session."""
26-
return uvloop.EventLoopPolicy()
24+
@pytest.hookimpl(optionalhook=True)
25+
def pytest_asyncio_loop_factories() -> dict[str, _t.Callable[[], asyncio.AbstractEventLoop]]:
26+
"""Configure pytest-asyncio to create event loops with uvloop."""
27+
return {"uvloop": uvloop.new_event_loop}
2728

2829

2930
@pytest.fixture(scope="session", autouse=True)

tests/unit/test_conftest.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"""Unit tests for the shared pytest configuration."""
2+
3+
import uvloop
4+
5+
from tests import conftest
6+
7+
8+
def test_pytest_asyncio_loop_factories_uses_uvloop() -> None:
9+
"""The shared pytest-asyncio hook should configure uvloop factories."""
10+
assert conftest.pytest_asyncio_loop_factories() == {"uvloop": uvloop.new_event_loop}

0 commit comments

Comments
 (0)