[config] load testing env when under pytest

This commit is contained in:
bronsen 2025-03-13 17:15:23 +01:00
parent 04cb10d13c
commit 30f6d6c8c1
2 changed files with 10 additions and 1 deletions

4
.env.test Normal file
View file

@ -0,0 +1,4 @@
DATABASE_URL=psql://teilchensammler:teilchensammler@localhost:5432/teilchensammler_test
DEBUG=On
SECRET_KEY=django-insecure-x=%#_wxu0h=d*m#seui9+mjh3vu7of8+4+gpwj@556.un0r1%.
DEV=On

View file

@ -10,13 +10,18 @@ https://docs.djangoproject.com/en/5.1/ref/settings/
import environ
from pathlib import Path
import sys
BASE_DIR = Path(__file__).resolve().parent.parent
env = environ.Env(
DEBUG=(bool, False),
DEV=(bool, False),
)
environ.Env.read_env(BASE_DIR / ".env")
if "pytest/__main__.py" in sys.argv[0]:
env.read_env(BASE_DIR / ".env.test")
else:
env.read_env(BASE_DIR / ".env")
# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/