Issue #28 invalid

Function declaration line shows as not executed

Jeremy Whitlock
created an issue

The coverage report for my app shows a function's contents as executed but says the line declaring the function was not. Here is an example:

{{{

!python

class Person(object): def init(self, name): self.name = name

def speak(self, msg):
    print(msg)

}}}

and here is an example usage during my coverage process:

{{{

!python

... p = Person("Jeremy") p.speak("I like coverage.py.") }}}

While this is purely an example, the report would tell me that lines 3 and 6 executed but not lines 2 and 5. I just updated to the latest version and I get the same result. (I tried with 3.0.1 and 3.1.)

I'm also seeing global-level comments and imports not being shown as executed either. So if I have:

{{{

!python

--python--

"""This is where the database code goes."""

import os, sys

... }}}

I end up with my report telling me lines 4-6 were not executed.

I've used this for a few Django-based projects before and never ran into problems like this and while it could be bad Python structure and/or user error, I figured this would be the place to start.

Comments (4)

  1. Jeremy Whitlock reporter

    Ned, Please forgive me. I'm usually pretty good at reading before assuming there is a problem. I am using the API and I bet that I'm not starting code coverage before the class is imported. Let me try again and I'll let you know.

  2. Log in to comment