[TIP] coverage.py vs QGIS

Skip Montanaro skip.montanaro at gmail.com
Tue Apr 14 12:01:29 PDT 2020


(First and foremost, I think you need to explain more about what you've
tried so far. Beyond that, as I've just gone through issues using
coverage.py in a multi-process setting, let me refer you to my recent
message and the thread it spawned:

http://lists.idyll.org/pipermail/testing-in-python/2020-April/007353.html

It seems you have a somewhat more complicated setup than I did, but I will
point you to this section of the docs:

https://coverage.readthedocs.io/en/coverage-5.1/subprocess.html

I advise you to read it carefully. I missed some things in my first
go-round, in particular this:

Measuring coverage in sub-processes is a little tricky. When you spawn a
sub-process, you are invoking Python to run your program. Usually, to get
coverage measurement, you have to use coverage.py to run your program. Your
sub-process *won’t be using coverage.py*, so we have to convince Python to
use coverage.py even when not explicitly invoked.

(emphasis mine)

The documentation section on command line execution:

https://coverage.readthedocs.io/en/coverage-5.1/cmd.html#execution

has this to say about complex multi-threaded/process/event situations:

Coverage.py can measure multi-threaded programs by default. If you are
using more exotic concurrency, with the multiprocessing, greenlet,
eventlet, or gevent libraries, then coverage.py will get very confused. Use
the --concurrency switch to properly measure programs using these
libraries. Give it a value of multiprocessing, thread, greenlet, eventlet,
or gevent. Values other than thread require the C extension.


I imagine it might be impossible to achieve perfection, but perhaps with
overlapping runs using different values for the --concurrency flag you
might get acceptable output.

Skip Montanaro



On Tue, Apr 14, 2020 at 8:11 AM Sebastian M. Ernst <ernst at pleiszenburg.de>
wrote:

> Hi all,
>
> I am trying to use `coverage.py` inside QGIS (1, 2). QGIS is a large
> hybrid C++/Python Qt-based application.
>
> Long story short: I am running into what appear to be nondeterministic
> race conditions plus a bunch of other issues. After reading the manual,
> I am guessing that with respect to QGIS' threads and Qt's event loops
> coverage.py is not meant to be used in this context ;)
>
> Question: Does anybody around here have any experience at all with
> coverage.py and QGIS or just coverage.py inside larger
> (C++/Qt/PyQt/hybrid) applications?
>
> Best regards,
> Sebastian
>
>
> 1: https://www.qgis.org
> 2: https://github.com/qgis/QGIS
>
> _______________________________________________
> 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/20200414/550cb634/attachment.htm>


More information about the testing-in-python mailing list