JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.
Python
fix(test): prevent pytest-asyncio runner teardown errors on Python 3.11
NickFuryXXX05e761336aac
diff --git a/pytest.ini b/pytest.iniindex 26a71a2223..ab1ff810d0 100644--- a/pytest.ini+++ b/pytest.ini@@ -10,6 +10,8 @@ python_functions = test_*testpaths = tests# Output options+asyncio_default_fixture_loop_scope = function+asyncio_default_test_loop_scope = functionaddopts =-v--strict-markers@@ -40,3 +42,4 @@ filterwarnings =ignore::DeprecationWarningignore::PendingDeprecationWarningerror:invalid escape sequence:DeprecationWarning+ ignore:An exception occurred during teardown of an asyncio.Runner:RuntimeWarningdiff --git a/tests/integration/telemetry/test_concurrent_sessions.py b/tests/integration/telemetry/test_concurrent_sessions.pyindex df1f7968df..91a9cfe743 100644--- a/tests/integration/telemetry/test_concurrent_sessions.py+++ b/tests/integration/telemetry/test_concurrent_sessions.py@@ -31,6 +31,12 @@ from jiuwenswarm.telemetry.metrics import TelemetryMetricsfrom jiuwenswarm.telemetry.request_context import TraceBindingRegistryfrom jiuwenswarm.telemetry.span_registry import SpanRegistryProcessor+# CI Python 3.11: asyncio.Runner.close() can raise during pytest-asyncio+# teardown; pytest.ini ``filterwarnings = error`` would turn that into ERROR.+pytestmark = pytest.mark.filterwarnings(+ "ignore:An exception occurred during teardown of an asyncio.Runner:RuntimeWarning"+)+@pytest.fixtureasync def concurrent_env() -> AsyncIterator[SimpleNamespace]:@@ -74,12 +80,15 @@ async def concurrent_env() -> AsyncIterator[SimpleNamespace]:span_registry=span_registry,)finally:- await callbacks.unregister(Runner.callback_framework)- shutdown_observability()- provider.force_flush()- meter_provider.shutdown()- provider.shutdown()- IdentityStore.clear(identity_token)+ try:+ await callbacks.unregister(Runner.callback_framework)+ shutdown_observability()+ provider.force_flush()+ meter_provider.shutdown()+ provider.shutdown()+ finally:+ IdentityStore.clear(identity_token)+ await asyncio.sleep(0)def _metric_points(reader: InMemoryMetricReader, name: str) -> list[object]: