OLD | NEW |
(Empty) | |
| 1 .. _contributing: |
| 2 |
| 3 =========================== |
| 4 Contributing to coverage.py |
| 5 =========================== |
| 6 |
| 7 :history: 20121112T154100, brand new docs. |
| 8 |
| 9 .. highlight:: console |
| 10 |
| 11 I welcome contributions to coverage.py. Over the years, dozens of people have |
| 12 provided patches of various sizes to add features or fix bugs. This page |
| 13 should have all the information you need to make a contribution. |
| 14 |
| 15 One source of history or ideas are the `bug reports`_ against coverage.py. |
| 16 There you can find ideas for requested features, or the remains of rejected |
| 17 ideas. |
| 18 |
| 19 .. _bug reports: https://bitbucket.org/ned/coveragepy/issues?status=new&status=o
pen |
| 20 |
| 21 |
| 22 Before you begin |
| 23 ---------------- |
| 24 |
| 25 If you have an idea for coverage.py, run it by me before you begin writing |
| 26 code. This way, I can get you going in the right direction, or point you to |
| 27 previous work in the area. Things are not always as straightforward as they |
| 28 seem, and having the benefit of lessons learned by those before you can save |
| 29 you frustration. |
| 30 |
| 31 |
| 32 Getting the code |
| 33 ---------------- |
| 34 |
| 35 The coverage.py code is hosted on a `Mercurial`_ repository at |
| 36 https://bitbucket.org/ned/coveragepy. To get a working environment, follow |
| 37 these steps: |
| 38 |
| 39 #. (Optional, but recommended) Create a virtualenv to work in, and activate |
| 40 it. |
| 41 |
| 42 #. Clone the repo:: |
| 43 |
| 44 $ hg clone https://bitbucket.org/ned/coveragepy |
| 45 |
| 46 #. Install the requirements:: |
| 47 |
| 48 $ pip install -r requirements.txt |
| 49 |
| 50 #. Install a number of versions of Python. Coverage.py supports a wide range |
| 51 of Python versions. The more you can test with, the more easily your code |
| 52 can be used as-is. If you only have one version, that's OK too, but may |
| 53 mean more work integrating your contribution. |
| 54 |
| 55 |
| 56 Running the tests |
| 57 ----------------- |
| 58 |
| 59 The tests are written as standard unittest-style tests, and are run with |
| 60 `tox`_:: |
| 61 |
| 62 $ tox |
| 63 GLOB sdist-make: /home/ned/coverage/setup.py |
| 64 py25 sdist-reinst: /home/ned/coverage/tox/dist/coverage-3.6b1.zip |
| 65 py25 runtests: commands[0] |
| 66 py25 runtests: commands[1] |
| 67 py25 runtests: commands[2] |
| 68 py25 runtests: commands[3] |
| 69 py25 runtests: commands[4] |
| 70 === Python 2.5.5 with Python tracer (/home/ned/coverage/tox/py25/bin/python)
=== |
| 71 ............................................................................
...............(etc) |
| 72 ---------------------------------------------------------------------- |
| 73 Ran 360 tests in 10.836s |
| 74 |
| 75 OK |
| 76 py25 runtests: commands[5] |
| 77 py25 runtests: commands[6] |
| 78 === Python 2.5.5 with C tracer (/home/ned/coverage/tox/py25/bin/python) === |
| 79 ............................................................................
...............(etc) |
| 80 ---------------------------------------------------------------------- |
| 81 Ran 360 tests in 10.044s |
| 82 |
| 83 OK |
| 84 py26 sdist-reinst: /home/ned/coverage/trunk/.tox/dist/coverage-3.6b1.zip |
| 85 py26 runtests: commands[0] |
| 86 py26 runtests: commands[1] |
| 87 py26 runtests: commands[2] |
| 88 py26 runtests: commands[3] |
| 89 py26 runtests: commands[4] |
| 90 === CPython 2.6.6 with Python tracer (/home/ned/coverage/tox/py26/bin/python
) === |
| 91 ............................................................................
...............(etc) |
| 92 ---------------------------------------------------------------------- |
| 93 Ran 364 tests in 12.572s |
| 94 |
| 95 OK |
| 96 py26 runtests: commands[5] |
| 97 py26 runtests: commands[6] |
| 98 === CPython 2.6.6 with C tracer (/home/ned/coverage/tox/py26/bin/python) === |
| 99 ............................................................................
...............(etc) |
| 100 ---------------------------------------------------------------------- |
| 101 Ran 364 tests in 11.458s |
| 102 |
| 103 OK |
| 104 (and so on...) |
| 105 |
| 106 Tox runs the complete test suite twice for each version of Python you have |
| 107 installed. The first run uses the Python implementation of the trace |
| 108 function, the second uses the C implementation. |
| 109 |
| 110 To limit tox to just a few versions of Python, use the ``-e`` switch:: |
| 111 |
| 112 $ tox -e py27,py33 |
| 113 |
| 114 To run just a few tests, you can use nose test selector syntax:: |
| 115 |
| 116 $ tox test.test_misc:SetupPyTest.test_metadata |
| 117 |
| 118 This looks in `test/test_misc.py` to find the `SetupPyTest` class, and runs the |
| 119 `test_metadata` test method. |
| 120 |
| 121 Of course, run all the tests on every version of Python you have, before |
| 122 submitting a change. |
| 123 |
| 124 |
| 125 Lint, etc |
| 126 --------- |
| 127 |
| 128 I try to keep the coverage.py as clean as possible. I use pylint to alert me |
| 129 to possible problems:: |
| 130 |
| 131 $ make lint |
| 132 pylint --rcfile=.pylintrc coverage setup.py test |
| 133 python -m tabnanny coverage setup.py test |
| 134 python igor.py check_eol |
| 135 |
| 136 The source is pylint-clean, even if it's because there are pragmas quieting |
| 137 some warnings. Please try to keep it that way, but don't let pylint warnings |
| 138 keep you from sending patches. I can clean them up. |
| 139 |
| 140 |
| 141 Coverage testing coverage.py |
| 142 ---------------------------- |
| 143 |
| 144 Coverage.py can measure itself, but it's complicated. The process has been |
| 145 packaged up to make it easier:: |
| 146 |
| 147 $ COVERAGE_COVERAGE=yes tox |
| 148 $ python igor.py combine_html |
| 149 |
| 150 Then look at htmlcov/index.html. Note that due to the recursive nature of |
| 151 coverage.py measuring itself, there are some parts of the code that will never |
| 152 appear as covered, even though they are executed. |
| 153 |
| 154 |
| 155 Contributing |
| 156 ------------ |
| 157 |
| 158 When you are ready to contribute a change, any way you can get it to me is |
| 159 probably fine. A pull request on Bitbucket is great, but a simple diff or |
| 160 patch is great too. |
| 161 |
| 162 |
| 163 .. _Mercurial: http://mercurial.selenic.com/ |
| 164 .. _tox: http://tox.testrun.org/ |
OLD | NEW |