1. Ned Batchelder
  2. coverage.py
  3. Issues
Issue #45 resolved

When I run my tests, imports statement and function declaration are not counted as covered

Batiste Bieler
created an issue

Hi,

Sorry in advance because it's probably not a bug in your software.

The prototype of my functions and imports are not reported as covered by in the report.

But the body of my functions if they are tested are said as covered. But not the imports at the top and the function declaration.

I am with a Django project here. And I have the latest version of coverage.

What could be wrong with my config?

Comments (2)

  1. Ned Batchelder repo owner

    This is one of the FAQs (http://nedbatchelder.com/code/coverage/faq.html). You need to start coverage earlier. There are Django-specific test runners that understand coverage (here's a recent post: http://chris.improbable.org/2010/01/28/django-site-test-coverage/). You can also simply take your python command that runs your tests, and run it under coverage instead:

    coverage.py run django-test-runner-however-you-do-it.py arg1 arg2 ...

  2. Batiste Bieler reporter

    I actually found that django-haystack was responsible for the coverage issue.

    Django-haystack seems to load itself very early, and every module imported in search_indexes.py will have the problem described belove.

  3. Log in to comment