<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#ffffff">
    If Alfredo's advice doesn't fix it, you can also run nose inside
    coverage instead of the usual way:<br>
    <br>
    &nbsp;&nbsp;&nbsp; $ coverage run nosetests.py<br>
    <br>
    Also, you can specify options to coverage using a .coveragerc file,
    so you could for example set the "source=" option to limit
    coverage's attention to a particular tree of files.<br>
    <br>
    --Ned.<br>
    <br>
    On 10/26/2010 7:56 AM, Alfredo Deza wrote:
    <blockquote
      cite="mid:AANLkTimkLhMGG1C-o+6gXHGqxjNfNq6WxbK-smxaRtZy@mail.gmail.com"
      type="cite"><br>
      <br>
      <div class="gmail_quote">On Mon, Oct 25, 2010 at 9:43 PM, Win
        Treese <span dir="ltr">&lt;<a moz-do-not-send="true"
            href="mailto:treese@acm.org">treese@acm.org</a>&gt;</span>
        wrote:<br>
        <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
          0.8ex; border-left: 1px solid rgb(204, 204, 204);
          padding-left: 1ex;">
          <br>
          I can't figure out why I'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>
          """Demonstrate coverage of library module."""<br>
          <br>
          import json<br>
          <br>
          def test_json():<br>
          &nbsp; print json.dumps({'a':3})<br>
          <br>
          <br>
          Run nose with coverage:<br>
          <br>
          % nosetests --with-cover<br>
          <br>
        </blockquote>
        <div>You are missing the "--cover-package" 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>&nbsp;</div>
        <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
          0.8ex; border-left: 1px solid rgb(204, 204, 204);
          padding-left: 1ex;">
          .<br>
          Name &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Stmts &nbsp; Miss &nbsp;Cover &nbsp; Missing<br>
          ---------------------------------------------------<br>
          encodings.hex_codec &nbsp; &nbsp; &nbsp;28 &nbsp; &nbsp; 28 &nbsp; &nbsp; 0% &nbsp; 9-71<br>
          json &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 39 &nbsp; &nbsp; 39 &nbsp; &nbsp; 0% &nbsp; 100-323<br>
          json.decoder &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;216 &nbsp; &nbsp;216 &nbsp; &nbsp; 0% &nbsp; 3-365<br>
          json.encoder &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;241 &nbsp; &nbsp;241 &nbsp; &nbsp; 0% &nbsp; 3-442<br>
          json.scanner &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 52 &nbsp; &nbsp; 52 &nbsp; &nbsp; 0% &nbsp; 3-67<br>
          ---------------------------------------------------<br>
          TOTAL &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 576 &nbsp; &nbsp;576 &nbsp; &nbsp; 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. &nbsp;<a moz-do-not-send="true"
            href="http://nedbatchelder.com/code/coverage"
            target="_blank">http://nedbatchelder.com/code/coverage</a><br>
          <br>
          &gt;From the documentation, I would expect those modules to be
          omitted. The coverage information is also incorrect, as if
          they are being reported, but not actually processed. I tried
          to trace it down through the code, but couldn't find the
          problem quickly.<br>
          <br>
          Thanks for any help,<br>
          <br>
          Win Treese<br>
          <a moz-do-not-send="true" href="mailto:treese@acm.org">treese@acm.org</a><br>
          <br>
          <br>
          <br>
          <br>
          _______________________________________________<br>
          testing-in-python mailing list<br>
          <a moz-do-not-send="true"
            href="mailto:testing-in-python@lists.idyll.org">testing-in-python@lists.idyll.org</a><br>
          <a moz-do-not-send="true"
            href="http://lists.idyll.org/listinfo/testing-in-python"
            target="_blank">http://lists.idyll.org/listinfo/testing-in-python</a><br>
        </blockquote>
      </div>
      <br>
      <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
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>
  </body>
</html>