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

batiste avatarbatiste created an issue


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

    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

    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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.