From 0c0ca440846416dd234f0a66888bdb5eb415822b Mon Sep 17 00:00:00 2001 From: Jason Staack Date: Sun, 15 Mar 2026 06:34:57 -0500 Subject: [PATCH] fix(ci): handle event loop closed during test teardown MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Catch RuntimeError in admin_session teardown cleanup — the event loop may be closed when the last test's fixtures are torn down. Co-Authored-By: Claude Opus 4.6 (1M context) --- backend/tests/integration/conftest.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/backend/tests/integration/conftest.py b/backend/tests/integration/conftest.py index 11c91bf..c4922d5 100644 --- a/backend/tests/integration/conftest.py +++ b/backend/tests/integration/conftest.py @@ -182,9 +182,12 @@ async def admin_session(admin_engine) -> AsyncGenerator[AsyncSession, None]: try: yield session finally: - if existing_tables: - await session.execute(text(f"TRUNCATE {tables_csv} CASCADE")) - await session.commit() + try: + if existing_tables: + await session.execute(text(f"TRUNCATE {tables_csv} CASCADE")) + await session.commit() + except RuntimeError: + pass # Event loop may be closed during final teardown await session.close()