Skip to content
This repository was archived by the owner on May 26, 2020. It is now read-only.

Commit 28ba02a

Browse files
committed
Update test settings
1 parent 5a85b18 commit 28ba02a

File tree

2 files changed

+60
-143
lines changed

2 files changed

+60
-143
lines changed

tests/conftest.py

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,68 @@
1-
import os
1+
def pytest_configure():
2+
from django.conf import settings
23

3-
import django
4-
from django.conf import settings
4+
settings.configure(
5+
DEBUG_PROPAGATE_EXCEPTIONS=True,
6+
DATABASES={
7+
'default': {
8+
'ENGINE': 'django.db.backends.sqlite3',
9+
'NAME': ':memory:'
10+
}
11+
},
12+
SITE_ID=1,
13+
SECRET_KEY='not very secret in tests',
14+
USE_I18N=True,
15+
USE_L10N=True,
16+
STATIC_URL='/static/',
17+
ROOT_URLCONF='tests.urls',
18+
TEMPLATE_LOADERS=(
19+
'django.template.loaders.filesystem.Loader',
20+
'django.template.loaders.app_directories.Loader',
21+
),
22+
MIDDLEWARE_CLASSES=(
23+
'django.middleware.common.CommonMiddleware',
24+
'django.contrib.sessions.middleware.SessionMiddleware',
25+
'django.middleware.csrf.CsrfViewMiddleware',
26+
'django.contrib.auth.middleware.AuthenticationMiddleware',
27+
'django.contrib.messages.middleware.MessageMiddleware',
28+
),
29+
INSTALLED_APPS=(
30+
'django.contrib.auth',
31+
'django.contrib.contenttypes',
32+
'django.contrib.sessions',
33+
'django.contrib.sites',
34+
'django.contrib.messages',
35+
'django.contrib.staticfiles',
536

37+
'tests',
38+
),
39+
PASSWORD_HASHERS=(
40+
'django.contrib.auth.hashers.MD5PasswordHasher',
41+
),
42+
)
643

7-
def pytest_configure():
8-
if not settings.configured:
9-
os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings'
44+
try:
45+
import oauth_provider # NOQA
46+
import oauth2 # NOQA
47+
except ImportError:
48+
pass
49+
else:
50+
settings.INSTALLED_APPS += (
51+
'oauth_provider',
52+
)
53+
54+
try:
55+
import provider # NOQA
56+
except ImportError:
57+
pass
58+
else:
59+
settings.INSTALLED_APPS += (
60+
'provider',
61+
'provider.oauth2',
62+
)
1063

1164
try:
65+
import django
1266
django.setup()
1367
except AttributeError:
1468
pass

tests/settings.py

Lines changed: 0 additions & 137 deletions
This file was deleted.

0 commit comments

Comments
 (0)