|Ned Batchelder : Blog | Code | Text | Site|
Coverage.py on Jython
» Home : Blog : May 2010
Coverage.py works in two steps: first, execute the code and record line numbers executed. Then analyze the code to identify parts that could have been executed but weren't. It turns out Jython provides the tool needed for the first (sys.settrace), but not the tools needed for the second (code.co_consts, and other internal representations of compiled code).
I was able to measure a Jython execution by running "coverage run" under Jython 2.5.1 to do the first step. Then I ran "coverage html" under CPython to complete the second step and get a report.
But I don't know if the line numbers will match up perfectly if the two steps are run under different interpreters. I'm looking for someone with a real Jython code base who'd like to try this technique and tell me what they find. Take the tip of the bitbucket repository, install it into your Jython and CPython installations, and run the two commands under the two different interpreters.
Drop me a line if you try this out, I'd love to be able to support Jython with coverage.py.