forked from orf/django-docker-box
-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathsettings.py
More file actions
71 lines (56 loc) · 2.05 KB
/
settings.py
File metadata and controls
71 lines (56 loc) · 2.05 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
"""Generic generated settings module supporting all database backends."""
import os
from typing import Any
def _build_databases_setting() -> dict[str, Any]:
engine = os.environ["DATABASE_ENGINE"]
host = os.environ.get("DATABASE_HOST", "")
name = os.environ.get("DATABASE_NAME", "")
settings = {}
for n, alias in enumerate(("default", "other"), start=1):
settings[alias] = entry = {"ENGINE": engine}
if not engine.endswith((".sqlite3", ".spatialite")):
entry |= {
"HOST": host,
"NAME": "django" if n < 2 else f"django{n}",
"USER": "django",
"PASSWORD": "django",
}
if engine.endswith(".mysql"):
entry["TEST"] = {"CHARSET": "utf8mb4"}
if engine.endswith(".oracle"):
entry |= {
"NAME": name,
"TEST": {
"USER": f"{alias}_test",
"TBLSPACE": f"{alias}_test_tbls",
"TBLSPACE_TMP": f"{alias}_test_tbls_tmp",
},
}
return settings
CACHES = {
"default": {
"BACKEND": "django.core.cache.backends.locmem.LocMemCache",
},
"pymemcache": {
"BACKEND": "django.core.cache.backends.memcached.PyMemcacheCache",
"LOCATION": "memcached-1:11211",
"KEY_PREFIX": "pymemcache:",
},
"pylibmc": {
"BACKEND": "django.core.cache.backends.memcached.PyLibMCCache",
"LOCATION": "memcached-2:11211",
"KEY_PREFIX": "pylibmc:",
},
"redis-py": {
"BACKEND": "django.core.cache.backends.redis.RedisCache",
"LOCATION": "redis://redis:6379",
"KEY_PREFIX": "redis:",
},
}
DATABASES = _build_databases_setting()
PASSWORD_HASHERS = ["django.contrib.auth.hashers.MD5PasswordHasher"]
SECRET_KEY = "django_tests_secret_key" # noqa: S105
USE_TZ = False
if os.environ.get("XUNIT", "0").lower() in {"1", "on", "true", "yes"}:
TEST_RUNNER = "xmlrunner.extra.djangotestrunner.XMLTestRunner"
TEST_OUTPUT_DIR = "/django/output/xunit"