wendajia/backend/tests/conftest.py
2026-10-17 18:22:39 +08:00

16 lines
662 B
Python

import os
import tempfile
from pathlib import Path
# Never let the integration tests inherit a development or production MySQL
# URL. The application is imported during test collection, so the isolated
# database must be selected before any test module imports app.main.
_test_dir = Path(tempfile.mkdtemp(prefix="wendajia-tests-"))
os.environ["DATABASE_URL"] = f"sqlite:///{(_test_dir / 'app.db').as_posix()}"
os.environ["SCREENSHOT_STORAGE_DIR"] = str(_test_dir / "screenshots")
os.environ["ADMIN_USERNAME"] = "admin"
os.environ["ADMIN_PASSWORD"] = "admin123456"
os.environ["OPERATOR_USERNAME"] = "operator"
os.environ["OPERATOR_PASSWORD"] = "operator123456"