PageRenderTime 9ms CodeModel.GetById 1ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/functional_tests/doc_tests/test_coverage_html/coverage_html.rst

https://bitbucket.org/jpellerin/nose/
ReStructuredText | 57 lines | 47 code | 10 blank | 0 comment | 0 complexity | a1f45571503d158e803b32233b6ff128 MD5 | raw file
 1Generating HTML Coverage with nose
 2----------------------------------
 3
 4.. Note ::
 5
 6    HTML coverage requires Ned Batchelder's `coverage.py`_ module.
 7..
 8
 9Console coverage output is useful but terse. For a more browseable view of
10code coverage, the coverage plugin supports basic HTML coverage output.
11
12.. hide this from the actual documentation:
13    >>> from nose.plugins.plugintest import run_buffered as run
14    >>> import os
15    >>> support = os.path.join(os.path.dirname(__file__), 'support')
16    >>> cover_html_dir = os.path.join(support, 'cover')
17    >>> cover_file = os.path.join(os.getcwd(), '.coverage')
18    >>> if os.path.exists(cover_file):
19    ...     os.unlink(cover_file)
20    ...
21
22
23The console coverage output is printed, as normal.
24
25    >>> from nose.plugins.cover import Coverage
26    >>> cover_html_dir = os.path.join(support, 'cover')
27    >>> run(argv=[__file__, '-v', '--with-coverage', '--cover-package=blah', 
28    ...           '--cover-html', '--cover-html-dir=' + cover_html_dir,
29    ...           support, ], 
30    ...     plugins=[Coverage()]) # doctest: +REPORT_NDIFF
31    test_covered.test_blah ... hi
32    ok
33    <BLANKLINE>
34    Name    Stmts   Miss  Cover   Missing
35    -------------------------------------
36    blah        4      1    75%   6
37    ----------------------------------------------------------------------
38    Ran 1 test in ...s
39    <BLANKLINE>
40    OK
41
42The html coverage reports are saved to disk in the directory specified by the
43``--cover-html-dir`` option. In that directory you'll find ``index.html``
44which links to a detailed coverage report for each module in the report. The
45detail pages show the module source, colorized to indicated which lines are
46covered and which are not. There is an example of this HTML output in the
47`coverage.py`_ docs.
48
49.. hide this from the actual documentation:
50    >>> os.path.exists(cover_file)
51    True
52    >>> os.path.exists(os.path.join(cover_html_dir, 'index.html'))
53    True
54    >>> os.path.exists(os.path.join(cover_html_dir, 'blah.html'))
55    True
56
57.. _`coverage.py`: http://nedbatchelder.com/code/coverage/