<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
On 25/11/2011 11:55, John Anderson wrote:
<blockquote
cite="mid:CAOdFaDXLcArKa7Kpd2EBauVNKJxvGnSiGubvhP+7ssy-qo6CLA@mail.gmail.com"
type="cite">I have a base class that all my models inherit from:
<div><br>
</div>
<div><a moz-do-not-send="true" href="http://paste2.org/p/1796621">http://paste2.org/p/1796621</a></div>
<div><br>
</div>
<div>and majority of my tests are touching models and I even have
tests against this specific class:</div>
<div><br>
</div>
<div><a moz-do-not-send="true" href="http://paste2.org/p/1796622">http://paste2.org/p/1796622</a></div>
<div><br>
</div>
<div>Yet, when I run a coverage test in py.test:</div>
<div>py.test --cov-report=term-missing --cov app/models.py</div>
<div><br>
</div>
<div>
<div>app/models 46 23 50% 1-27, 37-40, 59, 65, 76,
82-84</div>
</div>
<div><br>
</div>
<div><br>
</div>
<div>How are lines 1-27 not covered?</div>
</blockquote>
<br>
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.<br>
<br>
You need to run your tests under the coverage tool, or ensure that
coverage tracing is started before any imports execute.<br>
<br>
All the best,<br>
<br>
Michael Foord<br>
<br>
<blockquote
cite="mid:CAOdFaDXLcArKa7Kpd2EBauVNKJxvGnSiGubvhP+7ssy-qo6CLA@mail.gmail.com"
type="cite">
<div><br>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
testing-in-python mailing list
<a class="moz-txt-link-abbreviated" href="mailto:testing-in-python@lists.idyll.org">testing-in-python@lists.idyll.org</a>
<a class="moz-txt-link-freetext" href="http://lists.idyll.org/listinfo/testing-in-python">http://lists.idyll.org/listinfo/testing-in-python</a>
</pre>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
<a class="moz-txt-link-freetext" href="http://www.voidspace.org.uk/">http://www.voidspace.org.uk/</a>
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 <a class="moz-txt-link-freetext" href="http://www.sqlite.org/different.html">http://www.sqlite.org/different.html</a>
</pre>
</body>
</html>