summaryrefslogtreecommitdiff
path: root/doc/index.rst
blob: e3492d0501a14f43f230f25080e4233d2020717d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
===========
coverage.py
===========

.. toctree::
    :hidden:

    cmd
    api


Coverage.py is a tool for measuring code coverage of Python programs. It monitors
your program, noting which parts of the code have been executed, then analyzes the
source to identify code that could have been executed but was not.


Quick Start
-----------

Install coverage.py from the cheeseshop.

Run coverage.py to execute your program and gather data::

    $ coverage -e -x my_program.py
    blah blah your program's output blah blah
    
Run coverage.py to report on the results::

    $ coverage -r -m 
    Name                      Stmts   Exec  Cover   Missing
    -------------------------------------------------------
    my_program                   20     16    80%   33-35, 39
    my_other_module              56     50    89%   517-523
    -------------------------------------------------------
    TOTAL                        76     66    87%

For a nicer presentation, run coverage.py to get annotated HTML listings
detailing missed lines::

    coverage -b -d htmlcov

Then visit htmlcov/index.html in your browser.


Using coverage.py
-----------------

There are two supported interfaces to coverage: a :ref:`command line <cmd>` and
an :ref:`API <api>`.