diff --git a/tests/unit/langgraph/test_bridge.py b/tests/unit/langgraph/test_bridge.py index c565b925..4e5ad5db 100644 --- a/tests/unit/langgraph/test_bridge.py +++ b/tests/unit/langgraph/test_bridge.py @@ -20,8 +20,21 @@ from rx.scheduler.eventloop import AsyncIOScheduler @pytest.fixture def scheduler(): - """Fixture for AsyncIO scheduler.""" - return AsyncIOScheduler(loop=asyncio.get_event_loop()) + """Fixture for AsyncIO scheduler. + + Note: This fixture works for both sync and async tests. It attempts to use + the running event loop (for async test contexts), or creates a new one if + needed (for sync test contexts). This avoids the Python 3.12+ deprecation + warning for asyncio.get_event_loop() when no loop exists. + """ + try: + # Try to get the running loop (for async test contexts) + loop = asyncio.get_running_loop() + except RuntimeError: + # No running loop - create a new one for sync tests + loop = asyncio.new_event_loop() + asyncio.set_event_loop(loop) + return AsyncIOScheduler(loop=loop) @pytest.fixture