Skip to content

Commit 9f1265b

Browse files
committed
Update test-runner for Django 1.2+.
1 parent 5ce66f2 commit 9f1265b

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

tests/runtests.py

+26-6
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,36 @@
22

33
import os, sys
44

5-
parent = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
6-
sys.path.insert(0, parent)
5+
from django.conf import settings
76

8-
os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.test_settings'
97

10-
from django.test.simple import run_tests
8+
if not settings.configured:
9+
settings_dict = dict(
10+
INSTALLED_APPS=['form_utils', 'tests'],
11+
DATABASES={
12+
"default": {
13+
"ENGINE": "django.db.backends.sqlite3",
14+
}
15+
},
16+
MEDIA_ROOT=os.path.join(os.path.dirname(__file__), 'media'),
17+
MEDIA_URL='/media/',
18+
)
1119

12-
def runtests():
13-
failures = run_tests(['tests'], verbosity=1, interactive=True)
20+
settings.configure(**settings_dict)
21+
22+
23+
def runtests(*test_args):
24+
if not test_args:
25+
test_args = ['tests']
26+
27+
parent = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
28+
sys.path.insert(0, parent)
29+
30+
from django.test.simple import DjangoTestSuiteRunner
31+
failures = DjangoTestSuiteRunner(
32+
verbosity=1, interactive=True, failfast=False).run_tests(test_args)
1433
sys.exit(failures)
1534

35+
1636
if __name__ == '__main__':
1737
runtests()

0 commit comments

Comments
 (0)