[TIP] Getting Weird Coverage Reports

Ned Batchelder ned at nedbatchelder.com
Sat Nov 26 13:31:42 PST 2011


On 11/25/2011 6:55 AM, John Anderson wrote:
> I have a base class that all my models inherit from:
>
> http://paste2.org/p/1796621
>
> and majority of my tests are touching models and I even have tests 
> against this specific class:
>
> http://paste2.org/p/1796622
>
> Yet, when I run a coverage test in py.test:
> py.test --cov-report=term-missing --cov app/models.py
>
> app/models      46     23    50%   1-27, 37-40, 59, 65, 76, 82-84
>
>
> How are lines 1-27 not covered?
>
You can always start coverage as early as possible by using coverage to 
run the test runner, instead of having the test runner invoke coverage:

     $ coverage run /path/to/py.test etc etc

--Ned.




More information about the testing-in-python mailing list