Commits

Anonymous committed aae5c2e

added get_base_runner function build test runner from COVERAGE_WRAPPED_TEST_RUNNER settings property falling back on djangos simple test runner when this is not available.

Comments (0)

Files changed (1)

django_coverage/coverage_runner.py

 
 from django_coverage import settings
 from django.db.models import get_app, get_apps
-from django.test.simple import run_tests as base_run_tests
+from django.conf import settings as django_settings
 
 from utils.module_tools import get_all_modules
 from utils.coverage_report import html_report
 
+
+def get_base_runner():
+    if hasattr(django_settings, 'COVERAGE_WRAPPED_TEST_RUNNER'):
+        test_path = django_settings.COVERAGE_WRAPPED_TEST_RUNNER.split('.')
+        # Allow for Python 2.5 relative paths
+        if len(test_path) > 1:
+            test_module_name = '.'.join(test_path[:-1])
+        else:
+            test_module_name = '.'
+        test_module = __import__(test_module_name, {}, {}, test_path[-1])
+        test_runner = getattr(test_module, test_path[-1])
+        return test_runner
+    else:
+        from django.test.simple import run_tests as base_run_tests
+        return base_run_tests
+
+
+
 def _get_app_package(app_model_module):
     """
     Returns the app module name from the app model module.
     for e in settings.COVERAGE_CODE_EXCLUDES:
         coverage.exclude(e)
     coverage.start()
+    base_run_tests = get_base_runner()
     results = base_run_tests(test_labels, verbosity, interactive, extra_tests)
     coverage.stop()
 
             print >>sys.stdout
     else:
         outdir = os.path.abspath(outdir)
+        if not os.path.exists(outdir):
+            os.makedirs(outdir)
         if settings.COVERAGE_CUSTOM_REPORTS:
             html_report(outdir, modules, excludes, errors)
         else: