From 367512b52507cbfb29bd4c1af74ae550e1452171 Mon Sep 17 00:00:00 2001 From: Mgeeeek Date: Wed, 13 May 2026 20:51:03 +0530 Subject: [PATCH] test(server): document why StaticPool is required in test_engine fixture --- server/tests/conftest.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server/tests/conftest.py b/server/tests/conftest.py index 5f9d292e8..166317031 100644 --- a/server/tests/conftest.py +++ b/server/tests/conftest.py @@ -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},