Skip to content

Commit 18bd5da

Browse files
committed
Made possible to use DJANGO_SETTINGS_MODULE in testing
Also added a dummy test_pgsql settings file.
1 parent c1f7b3a commit 18bd5da

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

runtests.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
#!/usr/bin/env python
22
import sys
3+
import os
34
from os.path import dirname, abspath
45
from optparse import OptionParser
56

67
from django.conf import settings, global_settings
78

8-
if not settings.configured:
9+
# For convenience configure settings if they are not pre-configured or if we
10+
# haven't been provided settings to use by environment variable.
11+
if not settings.configured and not os.environ.get('DJANGO_SETTINGS_MODULE'):
912
settings.configure(
1013
DATABASES={
1114
'default': {

test_pgsql.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from django.conf import global_settings
2+
DATABASES={
3+
'default': {
4+
'ENGINE': 'django.db.backends.postgresql_psycopg2',
5+
# Edit the below settings before use...
6+
'USER': '',
7+
'NAME': '',
8+
'HOST': '',
9+
'PASSWORD': '',
10+
}
11+
}
12+
INSTALLED_APPS=[
13+
'django.contrib.auth',
14+
'django.contrib.admin',
15+
'django.contrib.contenttypes',
16+
'django.contrib.sessions',
17+
'django.contrib.sites',
18+
19+
'debug_toolbar',
20+
21+
'tests',
22+
]
23+
MIDDLEWARE_CLASSES=global_settings.MIDDLEWARE_CLASSES + (
24+
'debug_toolbar.middleware.DebugToolbarMiddleware',
25+
)
26+
ROOT_URLCONF=''
27+
DEBUG=False
28+
SITE_ID=1

0 commit comments

Comments
 (0)