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