Files
mxaccessgw/clients/python/tests/conftest.py
T
dohertj2 d6c2ca33f1
ci / live-mxaccess (push) Waiting to run
ci / windows (push) Failing after 13m38s
ci / java (push) Successful in 2m4s
ci / portable (push) Successful in 9m18s
CI: stand up Gitea Actions (TST-03) + fix the defects it caught (#123)
Make the authored CI pipeline execute and go green on the co-located runner (portable + java), fix the five real latent defects the first real run surfaced (codegen-check null, stale rust proto, orphan-terminator Linux path, stale java worker codegen, py3.12 event loop), provision pwsh + Gradle for the self-hosted act image, and disable the Windows jobs (act host-mode broken). TST-03 -> Done.

https://claude.ai/code/session_01DMXXvNuPekkkrTEyPNxEkW
2026-07-10 05:11:01 -04:00

28 lines
897 B
Python

"""Shared pytest fixtures for the client test suite.
pytest-asyncio 1.x no longer installs a current event loop for *synchronous*
tests, and it clears the loop after each ``async`` test. Some synchronous tests
build a ``grpc.aio.Channel`` (via ``create_channel``), which calls
``asyncio.get_event_loop()`` and therefore raises
``RuntimeError: There is no current event loop`` on Python 3.12 when a prior
async test has left the policy with no current loop. Ensure every test starts
with a usable current loop so channel construction in a sync test is
order-independent.
"""
from __future__ import annotations
import asyncio
from collections.abc import Iterator
import pytest
@pytest.fixture(autouse=True)
def _ensure_current_event_loop() -> Iterator[None]:
try:
asyncio.get_event_loop()
except RuntimeError:
asyncio.set_event_loop(asyncio.new_event_loop())
yield