Source / doc / faq.rst

FAQ and other help

history:20090613T141800, brand new docs.
history:20091005T073900, updated for 3.1.
history:20091127T201500, updated for 3.2.
history:20110605T175500, add the announcement mailing list.
history:20121231T104700, Tweak the py3 text.

Frequently asked questions

Q: I use nose to run my tests, and its cover plugin doesn't let me create HTML or XML reports. What should I do?

First run your tests and collect coverage data with nose and its plugin. This will write coverage data into a .coverage file. Then run from the :ref:`command line <cmd>` to create the reports you need from that data.

Q: Why do unexecutable lines show up as executed?

Usually this is because you've updated your code and run coverage on it again without erasing the old data. Coverage records line numbers executed, so the old data may have recorded a line number which has since moved, causing coverage to claim a line has been executed which cannot be.

If you are using the -x command line action, it doesn't erase first by default. Switch to the coverage run command, or use the -e switch to erase all data before starting the next run.

Q: Why do the bodies of functions (or classes) show as executed, but the def lines do not?

This happens because coverage is started after the functions are defined. The definition lines are executed without coverage measurement, then coverage is started, then the function is called. This means the body is measured, but the definition of the function itself is not.

To fix this, start coverage earlier. If you use the :ref:`command line <cmd>` to run your program with coverage, then your entire program will be monitored. If you are using the :ref:`API <api>`, you need to call coverage.start() before importing the modules that define your functions.

Q: Does work on Python 3.x?

Yes, Python 3 is fully supported.

Q: Isn't coverage testing the best thing ever?

It's good, but it isn't perfect.

Q: Where can I get more help with

You can discuss or get help using it on the Testing In Python mailing list.

Bug reports are gladly accepted at the Bitbucket issue tracker.

Announcements of new releases are sent to the coveragepy-announce mailing list.

I can be reached in a number of ways, I'm happy to answer questions about using I'm also available hourly for consultation or custom development.

History was originally written by Gareth Rees. Since 2004, Ned Batchelder has extended and maintained it with the help of many others. The :ref:`change history <changes>` has all the details.

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
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.