refine teardown
All checks were successful
Backend CI / unit-test (push) Successful in 25s

This commit is contained in:
2025-09-14 21:09:26 +02:00
parent 2c22f20b48
commit 7041cc654e
3 changed files with 2 additions and 2 deletions

View File

@@ -24,7 +24,6 @@ def engine() -> Generator[Engine, None, None]:
yield e
finally:
SQLModel.metadata.drop_all(e)
SQLModel.metadata.clear()
e.dispose()

View File

@@ -42,7 +42,6 @@ def database_ctx(db: Database) -> Generator[Database, None, None]:
yield db
finally:
db.dispose()
SQLModel.metadata.clear()
def test_select_one_executes() -> None:
@@ -77,6 +76,7 @@ def test_sqlite_pragmas_applied() -> None:
def test_rollback_on_exception() -> None:
db = create_database(None)
SQLModel.metadata.clear()
db.init_db()
with database_ctx(db):
# Create table then insert and raise inside the same session to force rollback

View File

@@ -13,6 +13,7 @@ def _base_type_of(compiled: str) -> str:
def test_run_migrations_0_to_1(monkeypatch: pytest.MonkeyPatch) -> None:
# in-memory engine that preserves the same connection (StaticPool)
SQLModel.metadata.clear()
engine = create_engine(
"sqlite:///:memory:",
connect_args={"check_same_thread": False},