Cover: code coverage

Note

Newer versions of coverage contain their own nose plugin which is superior to the builtin plugin. It exposes more of coverage’s options and uses coverage’s native html output. Depending on the version of coverage installed, the included plugin may override the nose builtin plugin, or be available under a different name. Check nosetests --help or nosetests --plugins to find out which coverage plugin is available on your system.

If you have Ned Batchelder’s coverage module installed, you may activate a coverage report with the --with-coverage switch or NOSE_WITH_COVERAGE environment variable. The coverage report will cover any python source module imported after the start of the test run, excluding modules that match testMatch. If you want to include those modules too, use the --cover-tests switch, or set the NOSE_COVER_TESTS environment variable to a true value. To restrict the coverage report to modules from a particular package or packages, use the --cover-packages switch or the NOSE_COVER_PACKAGES environment variable.

Options

--with-coverage

Enable plugin Coverage: Activate a coverage report using Ned Batchelder’s coverage module. [NOSE_WITH_COVERAGE]

--cover-package=PACKAGE

Restrict coverage output to selected packages [NOSE_COVER_PACKAGE]

--cover-erase

Erase previously collected coverage statistics before run

--cover-tests

Include test modules in coverage report [NOSE_COVER_TESTS]

--cover-inclusive

Include all python files under working directory in coverage report. Useful for discovering holes in test coverage if not all files are imported by the test suite. [NOSE_COVER_INCLUSIVE]

--cover-html

Produce HTML coverage information

--cover-html-dir=DIR

Produce HTML coverage information in dir

Plugin

class nose.plugins.cover.Coverage

Bases: nose.plugins.base.Plugin

Activate a coverage report using Ned Batchelder’s coverage module.

begin()

Begin recording coverage information.

configure(options, config)

Configure plugin.

options(parser, env)

Add options to command line.

report(stream)

Output code coverage report.

wantFile(file, package=None)

If inclusive coverage enabled, return true for all source files in wanted packages.

Source

Table Of Contents

Previous topic

Collect: Collect tests quickly

Next topic

Debug: drop into pdb on errors or failures

This Page