Mikhail Korobov avatar Mikhail Korobov committed 6a7279f

A better fix for South issues in 1.0 branch

Comments (0)

Files changed (2)

django_coverage/management/commands/test_coverage.py

 limitations under the License.
 """
 
-from django.core.management.base import BaseCommand
-from optparse import make_option
-import sys
+from django.conf import settings
+from django.core.management import call_command
+from django.core.management.commands import test
+from django_coverage import settings as coverage_settings
 
-def get_runner(settings):
-    test_path = settings.COVERAGE_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
 
-class Command(BaseCommand):
-    option_list = BaseCommand.option_list + (
-        make_option('--noinput', action='store_false', dest='interactive', default=True,
-            help='Tells Django to NOT prompt the user for input of any kind.'),
-    )
-    help = """\
-Runs the test suite for the specified applications, or the entire site if \
-no apps are specified. Then generates coverage report both onscreen and as HTML.
-"""
-    args = '[appname ...]'
-
-    requires_model_validation = False
-
-    def __init__(self):
-        super(Command, self).__init__()
-    #Added to allow django-coverage to work with south
-    #Code adapted from Marcin Swierczynski's blog
-    #http://blog.swierczynski.net/2010/07/code-coverage-analysis-in-django/
-	try:
-	    from south.management.commands import patch_for_test_db_setup
-	    patch_for_test_db_setup()
-	except ImportError:
-	    pass
+class Command(test.Command):
+    help = ("Runs the test suite for the specified applications, or the "
+            "entire site if no apps are specified. Then generates coverage "
+            "report both onscreen and as HTML.")
 
     def handle(self, *test_labels, **options):
-        from django_coverage import settings
-
-        verbosity = int(options.get('verbosity', 1))
-        interactive = options.get('interactive', True)
-        test_runner = get_runner(settings)
-
-        failures = test_runner(test_labels, verbosity=verbosity, interactive=interactive)
-        if failures:
-            sys.exit(failures)
-
+        """
+        Replaces the original test runner with the coverage test runner.
+        Then, call the test command. This plays well with apps that
+        override the test command, such as South.
+        """
+        settings.TEST_RUNNER = coverage_settings.COVERAGE_TEST_RUNNER
+        call_command('test', *test_labels, **options)
 
 setup(
       name='django-coverage',
-      version='1.0.1',
-      author='George Song, Mikhail Korobov',
-      author_email='george@55minutes.com, kmike84@gmail.com',
+      version='1.0.3',
+      author='George Song',
+      author_email='george@55minutes.com',
+      maintainer = 'Mikhail Korobov',
+      maintainer_email = 'kmike84@gmail.com',
       url = 'http://bitbucket.org/kmike/django-coverage/',
-      download_url = 'http://bitbucket.org/kmike/django-coverage/get/tip.zip',
+      download_url = 'http://bitbucket.org/kmike/django-coverage/get/1.0.3.gz',
 
       description = 'Django Test Coverage App',
       long_description = "A test coverage reporting tool that utilizes "
           'Intended Audience :: Developers',
           'License :: OSI Approved :: Apache Software License',
           'Programming Language :: Python',
-          'Topic :: Software Development :: Libraries :: Python Modules'
+          'Topic :: Software Development :: Libraries :: Python Modules',
+          'Topic :: Software Development :: Testing',
       ],
 )
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.