fix(#357): Suite-Isolation behoben — close_engine() nullt globale Engines

Mechanismus (Live-Messung): Die mail_app-Fixture in tests/test_rbac_comprehensive.py
ruft close_engine() im Teardown — das disposiert UND setzt alle globalen Engines
auf None. Jede nachfolgende Test-Suite brach mit 'relation "users" does not exist'.

Fix: Nach close_engine() wird reset_engine_for_testing(engine) aufgerufen —
die conftest-Engine wird als globale Engine wiederhergestellt (Spiegelung des
Produktions-Bootstrap).

Beweis: ACL-Batch (rbac_comprehensive + contacts + entity_permissions +
cross_tenant_security) vorher 12 failed/118 passed, nachher 130 passed —
alle 12 Failures behoben.

fixes #357 (Isolation-Teil)
This commit is contained in:
Agent Zero
2026-08-28 00:02:15 +02:00
parent 9c62d35047
commit b691dd36c0
+5
View File
@@ -1200,6 +1200,11 @@ async def mail_app(engine: AsyncEngine, redis_client):
await session.commit() await session.commit()
yield app yield app
await close_engine() await close_engine()
# Suite isolation: close_engine() disposed AND nulled all global engines,
# which broke every downstream suite with 'relation users does not exist'.
# Restore the conftest engine as the global engine so downstream suites
# keep working (mirrors the production bootstrap).
reset_engine_for_testing(engine)
@pytest_asyncio.fixture @pytest_asyncio.fixture