[TIP] live coverage info during running program
René Dudfield
renesd at gmail.com
Thu Jun 9 01:29:46 PDT 2016
Run my_program() as a separate process?
On Wed, Jun 8, 2016 at 7:15 PM, Joel B. Mohler <joel at kiwistrawberry.us>
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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20160609/407efe1c/attachment.html>
More information about the testing-in-python
mailing list