Test-Engine pro Test statt Modul-Global erzeugen (echter Fix für Event-Loop-Konflikt)
CI / backend-tests (push) Failing after 28s

Der vorherige Fix (asyncio_default_fixture_loop_scope/asyncio_default_test_loop_scope)
griff nicht - letztere Option existiert in der gepinnten pytest-asyncio-Version
vermutlich noch nicht, Tests liefen weiterhin auf function-scoped Loops während die
Engine session-weit global war. Echte Ursache behoben: db_session erzeugt jetzt eine
frische AsyncEngine pro Test (und disposed sie danach), sodass Engine/Pool immer auf
derselben Loop laufen wie der Test selbst.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L85hmKbvX7Cqkq47KnQhFt
This commit is contained in:
2026-09-03 23:27:06 +02:00
co-authored by Claude Sonnet 5
parent 8f9bd57c5b
commit 67cebbbf48
6 changed files with 280 additions and 30 deletions
-6
View File
@@ -1,10 +1,4 @@
[pytest]
asyncio_mode = auto
# Fund im ersten echten CI-Lauf: der globale engine in conftest.py wird einmal beim Import
# erzeugt, asyncpg-Verbindungen sind an die Event-Loop gebunden, in der sie entstanden sind.
# Ohne session-weiten Loop-Scope erzeugt pytest-asyncio pro Test eine neue Loop ->
# "RuntimeError: Task ... got Future ... attached to a different loop".
asyncio_default_fixture_loop_scope = session
asyncio_default_test_loop_scope = session
addopts = --cov=app --cov-report=term-missing --cov-fail-under=50
testpaths = tests