fix(ci): clean up test data before AND after each test
Prevents stale data from prior tests/runs from causing false failures like test_list_devices_empty finding leftover devices. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -165,6 +165,13 @@ async def admin_session(admin_engine) -> AsyncGenerator[AsyncSession, None]:
|
||||
Cleanup deletes all rows from test tables after the test.
|
||||
"""
|
||||
session = AsyncSession(admin_engine, expire_on_commit=False)
|
||||
# Clean up any leftover data from previous tests/runs BEFORE yielding
|
||||
for table in _CLEANUP_TABLES:
|
||||
try:
|
||||
await session.execute(text(f"DELETE FROM {table}"))
|
||||
except Exception:
|
||||
pass
|
||||
await session.commit()
|
||||
try:
|
||||
yield session
|
||||
finally:
|
||||
|
||||
Reference in New Issue
Block a user