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.

Coverage measurement is typically used to gauge the effectiveness of tests. It can show which parts of your code are being exercised by tests, and which are not.

The latest version is 4.5.3, released March 9, 2019. It is supported on:

  • Python versions 2.6, 2.7, 3.3, 3.4, 3.5, 3.6, 3.7, and beta 3.8.
  • PyPy2 6.0 and PyPy3 6.0.
  • Jython 2.7.1, though only for running code, not reporting.
  • IronPython 2.7.7, though only for running code, not reporting.

Professional support for is available as part of the Tidelift Subscription. Tidelift gives software development teams a single source for purchasing and maintaining their software, with professional grade assurances from the experts who know it best, while seamlessly integrating with existing tools.

Quick start

Getting started is easy:

  1. Install from the page on the Python Package Index, or by using “pip install coverage”. For a few more details, see Installation.

  2. Use coverage run to run your program and gather data:

    # if you usually do:
    #   $ python arg1 arg2
    # then instead do:
    $ coverage run arg1 arg2
    blah blah ..your program's output.. blah blah
  3. Use coverage report to report on the results:

    $ coverage report -m
    Name                      Stmts   Miss  Cover   Missing
    -------------------------------------------------------                20      4    80%   33-35, 39           56      6    89%   17-23
    TOTAL                        76     10    87%
  4. For a nicer presentation, use coverage html to get annotated HTML listings detailing missed lines:

    $ coverage html

    Then visit htmlcov/index.html in your browser, to see a report like this.


There are a few different ways to use The simplest is the command line, which lets you run your program and see the results. If you need more control over how your project is measured, you can use the API.

Some test runners provide coverage integration to make it easy to use while running tests. For example, pytest has the pytest-cov plugin.

You can fine-tune’s view of your code by directing it to ignore parts that you know aren’t interesting. See Specifying source files and Excluding code from for details.

Getting help

If the FAQ doesn’t answer your question, you can discuss or get help using it on the Testing In Python mailing list.

Bug reports are gladly accepted at the GitHub issue tracker. GitHub also hosts the code repository.

Professional support for is available as part of the Tidelift Subscription.

I can be reached in a number of ways. I’m happy to answer questions about using