-
Notifications
You must be signed in to change notification settings - Fork 18
/
conftest.py
96 lines (84 loc) · 2.74 KB
/
conftest.py
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import os
import sys
import django
from django import conf
from django.core.files import temp as tempfile
sys.path.insert(0, os.path.dirname(__file__))
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'sandbox'))
def location(x):
os.path.join(os.path.dirname(os.path.realpath(__file__)), x)
def pytest_configure():
conf.settings.configure(
DATABASES={
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:',
}
},
DEBUG=False,
SITE_ID=1,
SECRET_KEY="the-secret-key",
EMAIL_BACKEND='django.core.mail.backends.console.EmailBackend',
ROOT_URLCONF='sandbox.urls',
INSTALLED_APPS=[
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'cid.apps.CidAppConfig',
'testapp',
],
STATICFILES_DIRS=(location('static/'),),
STATIC_ROOT=location('public'),
STATIC_URL='/static/',
MEDIA_ROOT=tempfile.gettempdir(),
MEDIA_URL='/media/',
TEMPLATE_CONTEXT_PROCESSORS=(
"django.contrib.auth.context_processors.auth",
"django.core.context_processors.request",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.core.context_processors.static",
"django.contrib.messages.context_processors.messages",
),
TEMPLATE_DIRS=(
location('templates'),
),
# Other settings go here
LOGGING={
'version': 1,
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(cid)s %(message)s' # noqa
},
'simple': {
'format': '%(levelname)s %(message)s'
}
},
'filters': {
'cid': {
'()': 'cid.log.CidContextFilter'
}
},
'handlers': {
'cid': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'verbose',
'filters': ['cid']
}
},
'loggers': {
'cid': {
'handlers': ['cid'],
'propagate': True,
'level': 'DEBUG'
}
}
}
)
django.setup()