diff --git a/helpdesk/tests/__init__.py b/helpdesk/tests/__init__.py index abe2f37a..807df353 100644 --- a/helpdesk/tests/__init__.py +++ b/helpdesk/tests/__init__.py @@ -1,6 +1,9 @@ -from os.path import dirname, basename, isfile -import glob +# import all test_*.py files in directory. +# neccessary for automatic discovery in django <= 1.5 +# http://stackoverflow.com/a/15780326/1382740 -# import all test_*.py files in directory -modules = glob.glob(dirname(__file__)+"/test_*.py") -__all__ = [basename(f)[:-3] for f in modules if isfile(f)] +import unittest + + +def suite(): + return unittest.TestLoader().discover("helpdesk.tests", pattern="test_*.py") diff --git a/quicktest.py b/quicktest.py index d4b5a911..cce174af 100644 --- a/quicktest.py +++ b/quicktest.py @@ -97,13 +97,13 @@ class QuickDjangoTest(object): # see: http://stackoverflow.com/questions/3841725/how-to-launch-tests-for-django-reusable-app try: - # Django <= 1.8 - from django.test.simple import DjangoTestSuiteRunner - test_runner = DjangoTestSuiteRunner(verbosity=1) - except ImportError: - # Django >= 1.8 + # Django >= 1.6 from django.test.runner import DiscoverRunner test_runner = DiscoverRunner(verbosity=1) + except ImportError: + # Django <= 1.5 + from django.test.simple import DjangoTestSuiteRunner + test_runner = DjangoTestSuiteRunner(verbosity=1) if django.VERSION >= (1, 7): django.setup()