added test running compatibility for django 1.8, workin in 1.6 and 1.7

This commit is contained in:
Alex Seeholzer 2015-06-12 15:30:54 +02:00
parent f5401b6887
commit 05625d0bfd

View File

@ -93,14 +93,27 @@ class QuickDjangoTest(object):
STATIC_URL = '/static/'
)
try:
# Django <= 1.8
from django.test.simple import DjangoTestSuiteRunner
test_runner = DjangoTestSuiteRunner(verbosity=1)
except ImportError:
# Django >= 1.8
from django.test.runner import DiscoverRunner
test_runner = DiscoverRunner(verbosity=1)
if django.VERSION >= (1, 7):
django.setup()
from django.test.simple import DjangoTestSuiteRunner
failures = DjangoTestSuiteRunner().run_tests(self.apps, verbosity=1)
failures = test_runner.run_tests(self.apps)
if failures:
sys.exit(failures)
# from django.test.simple import DjangoTestSuiteRunner
# failures = DjangoTestSuiteRunner().run_tests(self.apps, verbosity=1)
# if failures:
# sys.exit(failures)
if __name__ == '__main__':
"""
What do when the user hits this file from the shell.