I've been toying around with coverage.py, but can't seem to get it to gather coverage for the __main__
module.
I'm on Windows, and like to hack up scripts using IDLE. The edit-hit-F5 cycle is really convenient, fast, and fun. Unfortunately, it doesn't look like coverage.py is able (or willing) to gather coverage of the main module -- in the code below, it reports that no data is collected. My code looks like this:
import coverage
cov = coverage.coverage()
cov.start()
def CodeUnderTest():
print 'do stuff'
return True
assert CodeUnderTest()
cov.stop()
cov.save()
cov.html_report()
Anyone have any ideas? I've tried various options to coverage, but to no avail. It seems like the environment IDLE creates isn't very friendly towards coverage, since sys.modules['__main__']
points to a idle.pyw file, not the file its running.