-
Notifications
You must be signed in to change notification settings - Fork 144
/
conftest.py
49 lines (40 loc) · 1.23 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
from __future__ import absolute_import
import os.path
import sys
from django.conf import settings
sys.path.insert(0, os.path.dirname(__file__))
def pytest_configure(config):
if not settings.configured:
test_db = os.environ.get('DB', 'sqlite')
DATABASES = {
'default': {
'NAME': 'bitfield',
}
}
if test_db == 'postgres':
DATABASES['default'].update({
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'USER': 'postgres',
})
elif test_db == 'mysql':
DATABASES['default'].update({
'ENGINE': 'django.db.backends.mysql',
'USER': 'root',
})
elif test_db == 'sqlite':
DATABASES['default'].update({
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:',
})
else:
raise NotImplementedError
settings.configure(
DATABASES=DATABASES,
INSTALLED_APPS=[
'django.contrib.contenttypes',
'bitfield',
'bitfield.tests',
],
ROOT_URLCONF='',
DEBUG=False,
)