|Ned Batchelder : Blog | Code | Text | Site|
Contributing to coverage.py
» Home : Code : coverage.py
Created 12 November 2012
I welcome contributions to coverage.py. Over the years, dozens of people have provided patches of various sizes to add features or fix bugs. This page should have all the information you need to make a contribution.
One source of history or ideas are the bug reports against coverage.py. There you can find ideas for requested features, or the remains of rejected ideas.
If you have an idea for coverage.py, run it by me before you begin writing code. This way, I can get you going in the right direction, or point you to previous work in the area. Things are not always as straightforward as they seem, and having the benefit of lessons learned by those before you can save you frustration.
The tests are written as standard unittest-style tests, and are run with tox:
Tox runs the complete test suite twice for each version of Python you have installed. The first run uses the Python implementation of the trace function, the second uses the C implementation.
To limit tox to just a few versions of Python, use the -e switch:
To run just a few tests, you can use nose test selector syntax:
This looks in tests/test_misc.py to find the SetupPyTest class, and runs the test_metadata test method.
Of course, run all the tests on every version of Python you have, before submitting a change.
I try to keep the coverage.py as clean as possible. I use pylint to alert me to possible problems:
The source is pylint-clean, even if it’s because there are pragmas quieting some warnings. Please try to keep it that way, but don’t let pylint warnings keep you from sending patches. I can clean them up.
Coverage.py can measure itself, but it’s complicated. The process has been packaged up to make it easier:
Then look at htmlcov/index.html. Note that due to the recursive nature of coverage.py measuring itself, there are some parts of the code that will never appear as covered, even though they are executed.
When you are ready to contribute a change, any way you can get it to me is probably fine. A pull request on Bitbucket is great, but a simple diff or patch is great too.