test: close the coroutines that mocked create_task, wait_for, run_coroutine_threadsafe, spawn_background_task and AsyncMock sessions left unawaited (reported as unraisable warnings in unrelated later tests); the Spoolman recovery tests archive under their own tmp_path instead of the shared archive/

This commit is contained in:
maziggy
2026-10-21 13:18:54 +02:00
parent c1ea484a5a
commit ee2d6e69aa
6 changed files with 46 additions and 29 deletions
@@ -35,7 +35,11 @@ async def _complete(printer_id, status, update):
session = AsyncMock()
session.__aenter__ = AsyncMock(return_value=session)
session.__aexit__ = AsyncMock(return_value=False)
session.execute = AsyncMock(return_value=MagicMock())
# Plain mocks for what the reads return: an AsyncMock's results are
# AsyncMocks too, so a plain call on one (completed_at.astimezone(),
# .first()) leaves an unawaited coroutine, reported in a later test.
for read in ("execute", "get", "scalar", "scalars"):
setattr(session, read, AsyncMock(return_value=MagicMock()))
tasks_before = set(asyncio.all_tasks())
with (
patch("backend.app.main.async_session", return_value=session),