<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    On 2/11/14 11:50 AM, Alexander Todorov wrote:<br>
    <blockquote cite="mid:52FA54E1.8060901@redhat.com" type="cite">Hello
      folks,
      <br>
      I'm fairly new to coverage but I've noticed something strange.
      With the sample Python scripts (attached) which include modules I
      see the following:
      <br>
      <br>
      If starting coverage from its API the report says:
      <br>
      <br>
      # ./myprog
      <br>
      Hello __main__
      <br>
      Hello mymodule1
      <br>
      Hello mymodule2
      <br>
      <br>
      # coverage report
      <br>
      Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Stmts&nbsp;&nbsp; Miss&nbsp; Cover
      <br>
      -------------------------------
      <br>
      mymodule1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp; 100%
      <br>
      mymodule2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp; 100%
      <br>
      -------------------------------
      <br>
      TOTAL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp; 100%
      <br>
      <br>
      <br>
      If starting coverage from the command line:
      <br>
      <br>
      # coverage run ./myprog2
      <br>
      Hello __main__
      <br>
      Hello mymodule1
      <br>
      Hello mymodule2
      <br>
      <br>
      # coverage report
      <br>
      Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Stmts&nbsp;&nbsp; Miss&nbsp; Cover
      <br>
      -------------------------------
      <br>
      mymodule1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp; 100%
      <br>
      mymodule2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp; 100%
      <br>
      myprog2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp; 100%
      <br>
      -------------------------------
      <br>
      TOTAL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 9&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp; 100%
      <br>
      <br>
      <br>
      <br>
      The difference as seen is that the main program file is not
      reported. </blockquote>
    Because of the way coverage measurement works in CPython, it can
    only start measuring coverage at a function call.&nbsp; Your myprog.py
    calls coverage.start(), which makes coverage measurement start at
    the next function call, which is into another module.&nbsp; None of the
    code in myprog.py is measured because none of it happens within a
    function called between .start() and .end().<br>
    <blockquote cite="mid:52FA54E1.8060901@redhat.com" type="cite">On a
      larger project I'm trying to integrate coverage with I see exactly
      the opposite - the main program file is included in the report
      while the modules it includes are not (not all of them). All
      modules are in site-packages.
      <br>
    </blockquote>
    This sound like a separate problem, perhaps your modules are
    imported before coverage starts?<br>
    <br>
    --Ned.<br>
    <blockquote cite="mid:52FA54E1.8060901@redhat.com" type="cite">
      <br>
      <br>
      This is with coverage-3.7 on Fedora 20.
      <br>
      <br>
      <br>
      Any ideas or comments ? Is this a known issue or a bug?
      <br>
      <br>
      <br>
      Regards,
      <br>
      Alex
      <br>
      <br>
      <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>
  </body>
</html>