Skip to content

Latest commit

 

History

History
58 lines (41 loc) · 1.65 KB

api.rst

File metadata and controls

58 lines (41 loc) · 1.65 KB

Coverage.py API

There are a few different ways to use coverage.py programmatically.

The API to coverage.py is in a module called coverage. Most of the interface is in the coverage.Coverage class. Methods on the Coverage object correspond roughly to operations available in the command line interface. For example, a simple use would be:

import coverage

cov = coverage.Coverage()
cov.start()

# .. call your code ..

cov.stop()
cov.save()

cov.html_report()

Any of the methods can raise specialized exceptions described in api_exceptions.

Coverage.py supports plugins that can change its behavior, to collect information from non-Python files, or to perform complex configuration. See api_plugin for details.

If you want to access the data that coverage.py has collected, the coverage.CoverageData class provides an API to read coverage.py data files.

Note

Only the documented portions of the API are supported. Other names you may find in modules or objects can change their behavior at any time. Please limit yourself to documented methods to avoid problems.

For more intensive data use, you might want to access the coverage.py database file directly. The schema is subject to change, so this is for advanced uses only. dbschema explains more.

api_coverage api_exceptions api_module api_plugin api_coveragedata dbschema