When you call coverage.save() it seems to prevent anything else from being read in, for example, html reports. For example, the following program shows 2 lines covered (the bodies of f1 and f2):
import coverage cov = coverage.Coverage() cov.start() def f1(): print 2 def f2(): print 3 f1() #cov.save() f2() cov.html_report()
However, if you uncomment the "cov.save()" line, it only shows the body of f1() as covered -- it doesn't record the body of f2().
cov.html_report() has the same problem when it's run between f1() and f2().
I'm not sure if this behavior is intended, but the documentation of save() and html_report() don't mention it.
I encountered this behavior while trying to find a "quick and dirty" solution for finding coverage information for the server side of a client/server application. I added cov.start() to the server initialization and added cov.html_report() to an existing server call, with the plan on just making that call to write out the currently-collected coverage information.