"""https://github.com/jezdez/django-discover-runner"""
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.test import TestCase
from django.test.simple import DjangoTestSuiteRunner, reorder_suite

from django.utils.importlib import import_module

try:
    from django.utils.unittest import defaultTestLoader
except ImportError:
    try:
        from unittest2 import defaultTestLoader  # noqa
    except ImportError:
        raise ImproperlyConfigured("Couldn't import unittest2 default "
                                   "test loader. Please use Django >= 1.3 "
                                   "or install the unittest2 library.")


class DiscoverRunner(DjangoTestSuiteRunner):
    """
    A test suite runner that uses unittest2 test discovery.


    """
    def build_suite(self, test_labels, extra_tests=None, **kwargs):
        suite = None
        root = getattr(settings, 'TEST_DISCOVER_ROOT', '.')
        top_level = getattr(settings, 'TEST_DISCOVER_TOP_LEVEL', None)
        pattern = getattr(settings, 'TEST_DISCOVER_PATTERN', 'test*.py')

        if test_labels:
            suite = defaultTestLoader.loadTestsFromNames(test_labels)
            # if single named module has no tests, do discovery within it
            if not suite.countTestCases() and len(test_labels) == 1:
                suite = None
                root = import_module(test_labels[0]).__path__[0]

        if suite is None:
            suite = defaultTestLoader.discover(root,
                pattern=pattern, top_level_dir=top_level)

        if extra_tests:
            for test in extra_tests:
                suite.addTest(test)

        return reorder_suite(suite, (TestCase,))
@@ -174,75 +174,8 @@
 ase%0A
-from django.test.simple import DjangoTestSuiteRunner, reorder_suite
 %0A%0Afr
@@ -614,16 +614,168 @@
 ry.%22)%0A%0A%0A
+try:%0A    from django.test.runner import DiscoverRunner%0Aexcept ImportError:%0A    from django.test.simple import DjangoTestSuiteRunner, reorder_suite%0A%0A    
 class Di
@@ -811,28 +811,36 @@
 unner):%0A    
-%22%22%22%0A
+    %22%22%22%0A    
     A test s
@@ -889,24 +889,28 @@
 very.%0A%0A%0A
+    
     %22%22%22%0A
     def 
@@ -897,24 +897,28 @@
         %22%22%22%0A
+    
     def buil
@@ -973,32 +973,36 @@
 wargs):%0A        
+   
+ 
 suite = None%0A   
@@ -990,32 +990,36 @@
    suite = None%0A
+    
         root = g
@@ -1070,16 +1070,20 @@
         
+  
+  
 top_leve
@@ -1137,16 +1137,20 @@
 , None)%0A
+    
         
@@ -1223,16 +1223,20 @@
         
+  
+  
 if test_
@@ -1243,16 +1243,20 @@
 labels:%0A
+    
         
@@ -1329,16 +1329,20 @@
         
+ 
+   
 # if sin
@@ -1407,16 +1407,20 @@
         
+    
 if not s
@@ -1476,32 +1476,36 @@
                 
+ 
+   
 suite = None%0A   
@@ -1493,32 +1493,36 @@
    suite = None%0A
+    
                 
@@ -1579,16 +1579,20 @@
         
+    
 if suite
@@ -1601,16 +1601,20 @@
 s None:%0A
+    
         
@@ -1670,24 +1670,28 @@
             
+    
 pattern=patt
@@ -1729,16 +1729,20 @@
         
+   
+ 
 if extra
@@ -1741,32 +1741,36 @@
 if extra_tests:%0A
+    
             for 
@@ -1802,24 +1802,28 @@
             
+  
+  
 suite.addTes
@@ -1831,16 +1831,20 @@
 (test)%0A%0A
+    
         
@@ -1883,8 +1883,9 @@
 tCase,))
+%0A

Update test runner to work with Django 1.6