Issue #9 open

COVERAGE_IGNORE_TESTS

Vadim Lopatyuk
created an issue

I would appreciate the inclusion of my patch.

It's just small extension for ignore testing some apps.

Original code is here: http://djangosnippets.org/snippets/2211/

My suggestion is to add {{{

!python

Packages for test exlusion

COVERAGE_IGNORE_TESTS = getattr(settings, 'COVERAGE_IGNORE_TESTS', []) }}}

to the django_coverage/settings.py

and

{{{

!python

def build_suite(self, *args, **kwargs):
    suite = super(CoverageRunner, self).build_suite(*args, **kwargs)
    if not args[0] and not getattr(settings, 'RUN_ALL_TESTS', False):
        tests = []
        for case in suite:
            pkg = case.__class__.__module__.split('.')[0]
            if pkg not in settings.COVERAGE_IGNORE_TESTS:
                tests.append(case)
        suite._tests = tests
    return suite

}}}

to django_coverage/coverage_runner.py in CoverageRunner class.

Now we can exclude some tests from test suite just list app names like this

{{{ COVERAGE_IGNORE_TESTS = ( 'localeurl', 'django', 'debug_toolbar', 'modeltranslation', 'mptt' ) }}}

I just won't install hg for forking and pull requesting of three lines of code :) Thanks!

Comments (1)

  1. Mikhail Korobov repo owner
    • changed status to open

    Thanks! This is nice but I don't really know if it belongs to django-coverage because django-coverage can be used with custom test runners (it auto-inherits from settings.TEST_RUNNER if executed via test_coverage management command) and build_suite may interfere with them.

    If the goal is to exlude some modules from the coverage report there is already COVERAGE_MODULE_EXCLUDES option (it is reported as not working (#6) but I can't reproduce this, it works for me).

    I do see the value in providing easy test excluding functionality but I haven't decided if this belongs to django-coverage. It'll be great to hear other's opinions on this issue.

    For the reference: https://github.com/kmike/django-coverage/pull/1

  2. Log in to comment