Issue #9 open

COVERAGE_IGNORE_TESTS

Vadim Lopatyuk avatarVadim 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

# Packages for test exlusion
COVERAGE_IGNORE_TESTS = getattr(settings, 'COVERAGE_IGNORE_TESTS', [])

to the django_coverage/settings.py

and

    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
    • 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
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.