chore: consolidate platform split checks
Some checks failed
Dependency Audit / dependency-audit (push) Has been cancelled
Module Matrix / module-matrix (push) Has been cancelled

This commit is contained in:
2026-07-10 12:51:19 +02:00
parent 150b720f12
commit 635d25c74c
216 changed files with 23336 additions and 4077 deletions

26
tests/db_isolation.py Normal file
View File

@@ -0,0 +1,26 @@
from __future__ import annotations
from collections.abc import Iterator
from contextlib import contextmanager
from govoplan_core.db.session import DatabaseHandle, configure_database, get_database, reset_database, set_database
@contextmanager
def temporary_database(database_url: str) -> Iterator[DatabaseHandle]:
try:
previous_database = get_database()
except RuntimeError:
previous_database = None
database = configure_database(database_url)
should_dispose = database is not previous_database
try:
yield database
finally:
if should_dispose:
database.engine.dispose()
if previous_database is None:
reset_database()
else:
set_database(previous_database)