Coverage.py v3.4 beta 1 is available now. 3.4 brings improved source code specification. The --omit and --include switches have changed in an incompatible way, taking file patterns rather than prefixes, and a new --source switch specifies directories or modules to measure. Details are in the new page about specifying source files in the coverage.py docs. These changes should help people focus coverage.py on the code they really want to measure.

In addition, a few bug fixes have helped in this area: Jinja templates and doctest bodies are no longer measured, since they produced errors during reporting anyway.

One other notable change: coverage.py used to report the number of statements, and the number of executed statements. Now instead of executed statements, it reports missed statements. This is a better indicator of how well your code is covered, because it's clear what the goal is: zero missed statements.

Give this version a try. There have been lots of changes. Also, I hate to admit it: but this version has broken my own coverage measurement of coverage.py itself, and I haven't figured out why yet...

tagged: , » 4 reactions

Comments

[gravatar]
pankaj 5:02 AM on 22 Aug 2010

Hi Ned,
I've used lot of your works including coverage.py, thanks a lot for it.
I'm developing a software in cython. After a lot of searching i could not find a way to get coverage of cython files.
Do you have any idea about it or maybe point me in the right direction so that i may add hooks to coverage.py to get it to report cython files' coverage also.
If line coverage is not possible at least function coverage would be a nice addition :)
Regards

[gravatar]
Ned Batchelder 12:57 PM on 22 Aug 2010

@Pankaj: I've never used Cython, but my understanding is that it compiles to .c files, which are then compiled and run. Coverage.py won't be able to help measure inside .c code. Perhaps gcov?

[gravatar]
pankaj 12:57 AM on 23 Aug 2010

Thanks for your reply.
I know coverage.py cant help with the c files, but cython actually generates code to hook to python profilers (cProfile) so that cProfile can report cython function calls in its report. Maybe there's some way to make coverage.py get this information and report which functions in the cython files are covered.
So i'd like to know how coverage does it (some documentation/source) and some pointers as to where do i dig into its source to be able to modify it to report such information. I think it will be a nice feature.
Thanks again.

[gravatar]
John C 10:38 AM on 25 Aug 2010

Thanks Ned and keep up the excellent work: coverage.py rocks :-)

Add a comment:

name
email
Ignore this:
not displayed and no spam.
Leave this empty:
www
not searched.
 
Name and either email or www are required.
Don't put anything here:
Leave this empty:
URLs auto-link and some tags are allowed: <a><b><i><p><br><pre>.