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