[TIP] Getting Weird Coverage Reports
michael at voidspace.org.uk
Fri Nov 25 04:00:18 PST 2011
On 25/11/2011 11:55, John Anderson wrote:
> I have a base class that all my models inherit from:
> and majority of my tests are touching models and I even have tests
> against this specific class:
> 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?
All of those lines (imports, class definition, decorator application)
are executed at *import time* (i.e. when the module is first created).
The fact that those lines are reported as not covered implies to me that
you are starting the test run (and therefore importing your models)
before coverage is started.
You need to run your tests under the coverage tool, or ensure that
coverage tracing is started before any imports execute.
All the best,
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
May you do good and not evil
May you find forgiveness for yourself and forgive others
May you share freely, never taking more than you give.
-- the sqlite blessing http://www.sqlite.org/different.html
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the testing-in-python