diff --git a/.env.test b/.env.test new file mode 100644 index 0000000..e987881 --- /dev/null +++ b/.env.test @@ -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 diff --git a/config/settings.py b/config/settings.py index 1b34947..1ba5c58 100644 --- a/config/settings.py +++ b/config/settings.py @@ -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/