<br><br><div class="gmail_quote">On Mon, Oct 25, 2010 at 9:43 PM, Win Treese <span dir="ltr">&lt;<a href="mailto:treese@acm.org">treese@acm.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
I can&#39;t figure out why I&#39;m getting coverage reports for standard library modules with the (most excellent) coverage.py and (also most excellent) nose:<br>
<br>
Python source:<br>
<br>
% cat test.py<br>
&quot;&quot;&quot;Demonstrate coverage of library module.&quot;&quot;&quot;<br>
<br>
import json<br>
<br>
def test_json():<br>
   print json.dumps({&#39;a&#39;:3})<br>
<br>
<br>
Run nose with coverage:<br>
<br>
% nosetests --with-cover<br>
<br></blockquote><div>You are missing the &quot;--cover-package&quot; flag that specifies what package to track.</div><div><br></div><div>This is very useful because sometimes you need a report on a sub-package:</div><div>
<br></div><div>nosetests --with-cover --cover-package=foo.sub_foo</div><div><br></div><div>If you do not provide that flag, you are telling the tool to track coverage in everything that is touched by your</div><div>execution.</div>
<div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
.<br>
Name                  Stmts   Miss  Cover   Missing<br>
---------------------------------------------------<br>
encodings.hex_codec      28     28     0%   9-71<br>
json                     39     39     0%   100-323<br>
json.decoder            216    216     0%   3-365<br>
json.encoder            241    241     0%   3-442<br>
json.scanner             52     52     0%   3-67<br>
---------------------------------------------------<br>
TOTAL                   576    576     0%<br>
----------------------------------------------------------------------<br>
Ran 1 test in 0.012s<br>
<br>
This is on Mac OS X 10.6.4 with:<br>
<br>
$ python --version<br>
Python 2.7<br>
$ nosetests --version<br>
nosetests version 0.11.4<br>
$ coverage --version<br>
Coverage.py, version 3.4.  <a href="http://nedbatchelder.com/code/coverage" target="_blank">http://nedbatchelder.com/code/coverage</a><br>
<br>