PageRenderTime 45ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 1ms

/doc/index.rst

https://gitlab.com/0072016/coveragepy
ReStructuredText | 202 lines | 147 code | 55 blank | 0 comment | 0 complexity | aa21e74b05bff53c24f0f97c12abfe81 MD5 | raw file
  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. ===========
  4. Coverage.py
  5. ===========
  6. .. :history: 20090524T134300, brand new docs.
  7. .. :history: 20090613T164000, final touches for 3.0
  8. .. :history: 20090618T195900, minor tweaks
  9. .. :history: 20090707T205200, changes for 3.0.1
  10. .. :history: 20090913T084400, new command line syntax
  11. .. :history: 20091004T211900, version 3.1
  12. .. :history: 20091127T155100, version 3.2
  13. .. :history: 20091205T161429, version 3.2 for real.
  14. .. :history: 20100224T204700, version 3.3
  15. .. :history: 20100306T181500, version 3.3.1
  16. .. :history: 20100725T211700, updated for 3.4.
  17. .. :history: 20100820T151500, updated for 3.4b1.
  18. .. :history: 20100906T134700, updated for 3.4b2.
  19. .. :history: 20100919T163500, updated for 3.4 release.
  20. .. :history: 20110213T081200, claim true 3.2 compatibility.
  21. .. :history: 20110604T114800, update for 3.5b1
  22. .. :history: 20110629T082300, update for 3.5
  23. .. :history: 20110827T221800, update for 3.5.1b1
  24. .. :history: 20110923T081800, update for 3.5.1
  25. .. :history: 20120429T162100, updated for 3.5.2b1
  26. .. :history: 20120503T233800, updated for 3.5.2
  27. .. :history: 20120929T093500, updated for 3.5.3
  28. .. :history: 20121117T094900, Change from easy_install to pip.
  29. .. :history: 20121128T203700, Updated for 3.6b1.
  30. .. :history: 20121223T180600, Updated for 3.6b2.
  31. .. :history: 20121229T112300, Updated for 3.6b3.
  32. .. :history: 20130105T174000, Updated for 3.6
  33. .. :history: 20131005T210000, Updated for 3.7
  34. .. :history: 20131212T213300, Updated for 3.7.1
  35. .. :history: 20140924T073000, Updated for 4.0a1
  36. .. :history: 20150124T023900, Updated for 4.0a4
  37. .. :history: 20150216T201000, Updated for 4.0a5
  38. .. :history: 20150802T160200, Updated for 4.0b1
  39. .. :history: 20150822T092900, Updated for 4.0b2
  40. .. :history: 20150918T072700, Updated for 4.0
  41. .. :history: 20151013T103200, Updated for 4.0.1
  42. .. :history: 20151104T050900, updated for 4.0.2
  43. .. :history: 20151124T065900, updated for 4.0.3
  44. .. :history: 20160110T125900, updated for 4.1b1
  45. .. :history: 20160123T171300, updated for 4.1b2
  46. .. :history: 20160510T125300, updated for 4.1b3
  47. .. :history: 20160521T074500, udpated for 4.1
  48. .. :history: 20160726T161300, udpated for 4.2
  49. Coverage.py is a tool for measuring code coverage of Python programs. It
  50. monitors your program, noting which parts of the code have been executed, then
  51. analyzes the source to identify code that could have been executed but was not.
  52. Coverage measurement is typically used to gauge the effectiveness of tests. It
  53. can show which parts of your code are being exercised by tests, and which are
  54. not.
  55. .. ifconfig:: not prerelease
  56. The latest version is coverage.py 4.2, released July 26th 2016. It
  57. is supported on:
  58. * Python versions 2.6, 2.7, 3.3, 3.4, 3.5, and 3.6.
  59. * PyPy 4.0 and 5.1.
  60. * PyPy3 2.4.
  61. .. ifconfig:: prerelease
  62. The latest version is coverage.py 4.2b1, released July 4th 2016. It is
  63. supported on:
  64. * Python versions 2.6, 2.7, 3.3, 3.4, and 3.5.
  65. * PyPy 4.0 and 5.1.
  66. * PyPy3 2.4.
  67. **This is a pre-release build. The usual warnings about possible bugs
  68. apply.** The latest stable version is coverage.py 4.1, `described here`_.
  69. .. _described here: http://nedbatchelder.com/code/coverage
  70. Quick start
  71. -----------
  72. Getting started is easy:
  73. #. Install coverage.py from the `coverage.py page on the Python Package Index`_,
  74. or by using "pip install coverage". For a few more details, see
  75. :ref:`install`.
  76. #. Use ``coverage run`` to run your program and gather data:
  77. .. code-block:: console
  78. $ coverage run my_program.py arg1 arg2
  79. blah blah ..your program's output.. blah blah
  80. #. Use ``coverage report`` to report on the results:
  81. .. code-block:: console
  82. $ coverage report -m
  83. Name Stmts Miss Cover Missing
  84. -------------------------------------------------------
  85. my_program.py 20 4 80% 33-35, 39
  86. my_other_module.py 56 6 89% 17-23
  87. -------------------------------------------------------
  88. TOTAL 76 10 87%
  89. #. For a nicer presentation, use ``coverage html`` to get annotated HTML
  90. listings detailing missed lines:
  91. .. code-block:: console
  92. $ coverage html
  93. .. ifconfig:: not prerelease
  94. Then visit htmlcov/index.html in your browser, to see a
  95. `report like this`_.
  96. .. ifconfig:: prerelease
  97. Then visit htmlcov/index.html in your browser, to see a
  98. `report like this one`_.
  99. .. _coverage.py page on the Python Package Index: http://pypi.python.org/pypi/coverage
  100. .. _report like this: http://nedbatchelder.com/files/sample_coverage_html/index.html
  101. .. _report like this one: http://nedbatchelder.com/files/sample_coverage_html_beta/index.html
  102. Using coverage.py
  103. -----------------
  104. There are a few different ways to use coverage.py. The simplest is the
  105. :ref:`command line <cmd>`, which lets you run your program and see the results.
  106. If you need more control over how your project is measured, you can use the
  107. :ref:`API <api>`.
  108. Some test runners provide coverage integration to make it easy to use
  109. coverage.py while running tests. For example, `nose`_ has a `cover plug-in`_.
  110. You can fine-tune coverage.py's view of your code by directing it to ignore
  111. parts that you know aren't interesting. See :ref:`source` and :ref:`excluding`
  112. for details.
  113. .. _nose: http://nose.readthedocs.io
  114. .. _cover plug-in: https://nose.readthedocs.io/en/latest/plugins/cover.html
  115. .. _contact:
  116. Getting help
  117. ------------
  118. If the :ref:`FAQ <faq>` doesn't answer your question, you can discuss
  119. coverage.py or get help using it on the `Testing In Python`_ mailing list.
  120. .. _Testing In Python: http://lists.idyll.org/listinfo/testing-in-python
  121. Bug reports are gladly accepted at the `Bitbucket issue tracker`_.
  122. Bitbucket also hosts the `code repository`_. There is a `mirrored repo`_ on
  123. GitHub.
  124. .. _Bitbucket issue tracker: http://bitbucket.org/ned/coveragepy/issues
  125. .. _code repository: http://bitbucket.org/ned/coveragepy
  126. .. _mirrored repo: https://github.com/nedbat/coveragepy
  127. `I can be reached`_ in a number of ways. I'm happy to answer questions about
  128. using coverage.py.
  129. .. _I can be reached: http://nedbatchelder.com/site/aboutned.html
  130. More information
  131. ----------------
  132. .. toctree::
  133. :maxdepth: 1
  134. install
  135. cmd
  136. config
  137. source
  138. excluding
  139. branch
  140. subprocess
  141. api
  142. howitworks
  143. plugins
  144. contributing
  145. trouble
  146. faq
  147. changes