-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
27 lines (18 loc) · 872 Bytes
/
Copy pathconftest.py
File metadata and controls
27 lines (18 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""Root conftest.py — pre-imports app_main with create_tables patched to a no-op.
app_main.py calls create_tables() at module level which connects to Postgres.
By patching Base.metadata.create_all before the first import we keep the test
session entirely in SQLite (managed by tests/conftest.py fixtures).
Sets ENV=test so CeleryBackend is not activated during tests.
"""
import os
import sys
from unittest.mock import patch
os.environ.setdefault("ENV", "test")
import src.infrastructure.persistence.base # noqa: E402 — ensure module is imported before patch resolves
def _preload_app_main():
"""Import app_main exactly once with create_tables suppressed."""
if "src.app_main" in sys.modules:
return
with patch("src.infrastructure.persistence.base.Base.metadata.create_all"):
import src.app_main # noqa: F401
_preload_app_main()