After a long and feverish ten days spent poring over Python parse trees, I have an updated coverage.py to offer.

It does a better job identifying executable statements than the original version by Gareth Rees, which was confused by docstrings and global statements. And you can use code markers to exclude lines or suites from consideration as executable statements.

Enjoy!

In the end, this job required a three-pronged attack to get everything I needed out of a Python module. Line-oriented regular expressions found the exclusion markers, the parser module told me about tokens and line numbers, and the compiler module told me about execution semantics. There may be an easier way to get all the information I needed, but I couldn't find it.

tagged: , » react

Comments

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>.