Package: django-discoverage
Addscoverageto Django 1.6’s test
runner and Carl Meyer and Jannis Leidel’sdjango-discover-runner.Inspired bydjango-coverage.django-discoverage works with Django 1.4 and above. If you are using Django 1.4
or 1.5, django-discover-runner is required and will be automatically
installed. That package backports the implementation ofDiscoverRunnerincluded in Django 1.6.Quick usageTo run the tests, type:./manage.py test [options] [appname …]To run the tests without code coverage (i.e. rundjango-discover-runnerinstead), type:./manage.py test –no-coverage [options] [appname …]If you want to use the--no-coverageoption, make sure you adddiscoverageto yourINSTALLED_APPS.Detailed usageOne of the objectives of Django’sDiscoverRunner(previouslydjango-discover-runner) is to allow the separation of a Django app’s tests
from the code it’s testing. Since tests no longer reside in an app,django-discoverageneeds a different way to know which apps to include in
the coverage report. The runner does this in two ways which are discussed below.First, it tries to infer which apps you are testing from the name of the package
in which the test’s module lives. For example, if you have an appblogand
you test the view of the app in the moduletests.blog.test_views, the app
will be included in the coverage report. The same happens if the app is a
subpackage and appears inINSTALLED_APPSasmyproject.blog.This behavior is controlled by thePKG_NAME_APP_DISCOVERYsetting.Although not on by default, tested apps can also be guessed from the name of the
test’s module. For example, ifMODULE_NAME_APP_DISCOVERYisTrueand
there is a module namedtests.test_blog, theblogapp will be included
in the report. You can override the regular expression used to extract the app
name using theMODULE_NAME_DISCOVERY_PATTERNsetting.The second way in whichdjango-discoveragefinds apps is by looking for an
iterable of app names (named by defaultTESTS_APPS) in three places:On aTestCaseinstance in the suite.In theTestCasesubclass’s module (test*.pyby default).In theTestCasesubclass’s immediate package. IfMyTestCaseis in the
packagetests.myapp.test_views, the runner inspectstests.myapp. It
does not currently traverse parent packages.Let’s say you had the following test module,tests.blog.test_views:TESTS_APPS = ('blog',)

class MyTestCase(TestCase):
    TESTS_APPS = ('mycoolapp', 'myproject.anothercoolapp')
    ...All modules in the appsblog,mycoolapp, andmyproject.anothercoolappwill be included in the report along with any apps
listed intest.blog.TESTS_APPS.Modules specified inOMIT_MODULESwillnot, however, appear in the report.SettingsPKG_NAME_APP_DISCOVERYDetermines whether tested apps are guessed from a test module’s package
name. It is on by default.MODULE_NAME_APP_DISCOVERYDetermines whether tested apps are guessed from a test module’s name.MODULE_NAME_DISCOVERY_PATTERNA regular expression with a single capturing group that extracts the app name
from a module name (e.g. “blog” fromtest_blog). Defaults to"test_?(\w+)".TESTED_APPS_VAR_NAMEThe name of the iterabledjango-discoveragelooks for in the three places
listed above. Defaults toTESTS_APPS.COVERAGE_OMIT_MODULESModules not to be traced bycoverage. See thecoverage API
documentationfor more details. Defaults to['*test*'].COVERAGE_EXCLUDE_PATTERNSA list of regular expressions that impact coverage reporting. If a line of
tested code matches one of the patterns in the list, it will not count as a
missed line. See thecoverage API documentationfor more details.Defaults to:def get_absolute_url(self):def __unicode__(self):def __str__(self):Any statement withimport *in itChange Log1.0.0 (2013-08-27)HandleImproperlyConfiguredexception raised bydjango-discover-runnerThe runner is now successfully used in several projects so it’s moving to 1.0.0.7.2 (2013-06-19)Require django-discover-runner 1.0 which now backports Django 1.6’s
implementation ofDiscoverRunner.0.7.1 (2013-06-18)Only install django-discover-runner if the version of Django installed is
lower than 1.60.7.0 (2013-06-05)Support for Django 1.6 and its implementation ofDiscoverRunner.0.6.2 (2013-03-13)Change the default ofCOVERAGE_OMIT_MODULESback to['*test*']0.6.1 (2013-03-06)Include South’s test database patching0.6.0 (2013-02-05)Python 3 supportTest suite for app discovery methods--no-coverageoption