test(server): document why StaticPool is required in test_engine fixture

This commit is contained in:
Mgeeeek
2026-05-13 20:51:03 +05:30
parent 79e04c56f6
commit 367512b525
+7 -1
View File
@@ -35,7 +35,13 @@ os.environ.setdefault("POSTGRES_HOST", "localhost") # silence db url builder
@pytest.fixture
def test_engine():
"""Fresh in-memory SQLite engine per test (no cross-test pollution)."""
"""Fresh in-memory SQLite engine per test (no cross-test pollution).
StaticPool is non-negotiable: in-memory SQLite is scoped to a single
connection, so every Session must share it. Without StaticPool, rows
inserted via db_session would be invisible to the TestClient's overridden
get_db (each Session would get its own empty in-memory DB).
"""
engine = create_engine(
"sqlite:///:memory:",
connect_args={"check_same_thread": False},