Note
HTML coverage requires Ned Batchelder’s coverage.py module.
Console coverage output is useful but terse. For a more browseable view of code coverage, the coverage plugin supports basic HTML coverage output.
The console coverage output is printed, as normal.
>>> from nose.plugins.cover import Coverage
>>> cover_html_dir = os.path.join(support, 'cover')
>>> run(argv=[__file__, '-v', '--with-coverage', '--cover-package=blah',
... '--cover-html', '--cover-html-dir=' + cover_html_dir,
... support, ],
... plugins=[Coverage()])
test_covered.test_blah ... hi
ok
<BLANKLINE>
Name Stmts Miss Cover Missing
-------------------------------------
blah 4 1 75% 6
----------------------------------------------------------------------
Ran 1 test in ...s
<BLANKLINE>
OK
The html coverage reports are saved to disk in the directory specified by the --cover-html-dir option. In that directory you’ll find index.html which links to a detailed coverage report for each module in the report. The detail pages show the module source, colorized to indicated which lines are covered and which are not. There is an example of this HTML output in the coverage.py docs.