[TIP] live coverage info during running program

Ned Batchelder ned at nedbatchelder.com
Thu Jun 9 05:28:16 PDT 2016


This is a current limitation of these methods, as reported here: 
https://bitbucket.org/ned/coveragepy/issues/448/save-and-html_report-prevent-further

I haven't yet looked into what it would take to allow continued 
collection after the save().

--Ned.

On 6/8/16 1:15 PM, Joel B. Mohler wrote:
> Dear Python testers,
>
> I'm trying to get a nice feedback loop for coverage testing both a Python REST
> server and the client side GUI program.  I thought I could get coverage to
> produce an html report on some interval -- say every 5-10 seconds.  This
> doesn't seem to be a documented use-case ... or is it?
>
> Following the documentation, I've inserted:
>
> 	import coverage
> 	cov = coverage.Coverage()
> 	cov.start()
> 	sys.coverer = cov # stash this in a global place
> 	my_program()  # bunch of code
> 	cov.stop()
> 	cov.save()
> 	cov.html_report()
>
> Inside my_program (which is really a whole GUI event loop), I've kicked off a
> little chunk periodically to update the html:
>
> 	sys.coverer.save()
> 	sys.coverer.html_report()
> 	# attempt at hacking some result-caching by coverage
> 	sys.coverer._measured = True
>
> On the first time I come to my update-the-html code and I get an htmlcov
> directory that looks correct.  On the second and subsequent times, it looks as
> though it rewrites exactly the same html.
>
> Is this possible?  Is there other caching I need to defeat?  There is file hash
> checking code in the HtmlReport which I do not fully understand.
>
> I understand this might be slow.  I was hoping that I could get an up-to-date
> CoverageData object quickly then go htmlify it in the background.  That looks
> difficult since the HtmlReport takes a Coverage object not a CoverageData.
>
> Thanks,
> Joel
>
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python




More information about the testing-in-python mailing list