Set up proper test settings

This commit is contained in:
Tobias Kunze 2025-09-26 13:53:41 +02:00
parent 4e5388e514
commit 039b4a7031
2 changed files with 38 additions and 1 deletions

View file

@ -54,7 +54,7 @@ ignore = "E203,W503"
extend_exclude = "src/servala/static/mazer"
[tool.pytest.ini_options]
DJANGO_SETTINGS_MODULE = "servala.settings"
DJANGO_SETTINGS_MODULE = "servala.settings_test"
addopts = "-p no:doctest -p no:pastebin -p no:nose --cov=./ --cov-report=term-missing:skip-covered"
testpaths = "src/tests"
pythonpath = "src"

View file

@ -0,0 +1,37 @@
"""
Django test settings that extend the main settings.
This file imports all settings from the main settings module and
overrides/adds settings specific to testing.
"""
from servala.settings import * # noqa: F403, F401
SECRET_KEY = "test-secret-key-for-testing-only-do-not-use-in-production"
PASSWORD_HASHERS = [
"django.contrib.auth.hashers.MD5PasswordHasher",
]
class DisableMigrations:
def __contains__(self, item):
return True
def __getitem__(self, item):
return None
MIGRATION_MODULES = DisableMigrations()
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": ":memory:",
"OPTIONS": {"timeout": 10},
}
}
OSB_USERNAME = "testuser"
OSB_PASSWORD = "testpass"
EMAIL_BACKEND = "django.core.mail.backends.locmem.EmailBackend"