fix(test): add event loop cleanup to prevent CI test failures

Adds a 0.5s sleep after shutting down test services (ExecutionManager,
AgentServer, etc.) to ensure they fully clean up their event loops before
the next test starts. This prevents 'Event loop is closed' errors in CI
that were breaking the oauth_test.py fixture setup.

The issue occurred because:
1. SpinTestServer starts background services with their own event loops
2. When services shut down, event loops weren't fully cleaned up
3. Subsequent tests would encounter closed event loops

Fixes test isolation issue where review_routes_test.py would leave the
event loop in a bad state for tests running after it.
This commit is contained in:
Zamil Majdy
2026-01-23 17:13:26 -06:00
parent e95a9273e6
commit 27e93a39c1

View File

@@ -1,3 +1,4 @@
import asyncio
import inspect
import logging
import time
@@ -58,6 +59,11 @@ class SpinTestServer:
self.db_api.__exit__(exc_type, exc_val, exc_tb)
self.notif_manager.__exit__(exc_type, exc_val, exc_tb)
# Give services time to fully shut down
# This prevents event loop issues where services haven't fully cleaned up
# before the next test starts
await asyncio.sleep(0.5)
def setup_dependency_overrides(self):
# Override get_user_id for testing
self.agent_server.set_test_dependency_overrides(