[pytest-dev] pytest-cov +gevent reporting incorrect results

Ronny Pfannschmidt Ronny.Pfannschmidt at gmx.de
Wed Apr 17 17:22:46 CEST 2013


Hi Ofer,

last i worked on greenlets they created custom thread states for each 
greenlet

i vaugely remember that the trace function used by coverage (which is 
used by pytest-cov is thread-specific

im under the imppression, that this may be an issue with greenlets ot 
picking up trace functions

however i don't have the time to test that hypothesis soonish

a quick analysis however shows, that the greenlet module has a own 
settrace call

you might want to experiment with having coverage use the settrace 
function of greenlet as well

-- Ronny


On 04/17/2013 03:48 PM, Ofer Nave wrote:
> Anyone have experience using pytest-cov on a codebase that makes use of
> gevent greenlets?
>
> I just started using pytest-cov for the first time yesterday, and
> thought it'd be fun to try to get my test coverage from 85% to 100%.
> However, the last few reportedly not-covered lines are, in fact,
> executed multiple times. I'm 100% certain of this (it's a critical
> section, the whole system depends on it, and I've added print statements
> just to be dumbly sure).
>
> The only possibility that comes to mind is that perhaps this is because
> those sections of code are in a spawned greenlet, and maybe that messes
> with how pytest-cov works -- can't be sure because I don't know how it
> works. :)
>
> -ofer
> _______________________________________________
> Pytest-dev mailing list
> Pytest-dev at python.org
> http://mail.python.org/mailman/listinfo/pytest-dev



More information about the Pytest-dev mailing list