RandomZ / app /tests /test_background_tasks_stub.py
StormShadow308's picture
feat: async pipeline, job queue, generation hardening, and docs
732b14f
Raw
History Blame Contribute Delete
551 Bytes
"""Background task registry."""
from __future__ import annotations
import asyncio
import pytest
from app.api.background_tasks import spawn_background_task
@pytest.mark.asyncio
async def test_spawn_background_task_logs_unhandled_exception(caplog) -> None:
import logging
caplog.set_level(logging.ERROR)
async def _boom() -> None:
raise RuntimeError("task failed")
spawn_background_task(_boom())
await asyncio.sleep(0.05)
assert any("Unhandled exception in background task" in r.message for r in caplog.records)