api.rst 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. .. Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
  2. .. For details: https://bitbucket.org/ned/coveragepy/src/default/NOTICE.txt
  3. .. _api:
  4. ===============
  5. Coverage.py API
  6. ===============
  7. .. :history: 20090524T134300, brand new docs.
  8. .. :history: 20090613T164000, final touches for 3.0
  9. .. :history: 20100221T151500, docs for 3.3 (on the plane back from PyCon)
  10. .. :history: 20100725T211700, updated for 3.4.
  11. .. :history: 20121111T235800, added a bit of clarification.
  12. .. :history: 20140819T132600, change class name to Coverage
  13. The API to coverage.py is very simple, contained in a module called `coverage`.
  14. Most of the interface is in the :class:`coverage.Coverage` class. Methods on
  15. the Coverage object correspond roughly to operations available in the command
  16. line interface. For example, a simple use would be::
  17. import coverage
  18. cov = coverage.Coverage()
  19. cov.start()
  20. # .. call your code ..
  21. cov.stop()
  22. cov.save()
  23. cov.html_report()
  24. The :class:`coverage.CoverageData` class provides access to coverage data
  25. stored in coverage.py data files.
  26. .. toctree::
  27. :maxdepth: 1
  28. api_coverage
  29. api_coveragedata
  30. api_plugin