Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nosetests coverage including Python packages

I'm using nosetests to run a few unit tests and show me our code coverage using something like:

nosetests -w ./test --with-xunit --with-coverage --cover-tests

This works well except for the fact that I'm seeing a bunch of Python packages in the output. Here's a sample:

ctypes._endian                 34     12    35%   15-20, 24-32, 50-60
ctypes.macholib                 1      1   100%   
email                          29     25    86%   56-57, 65-66
email.errors                   15     14    93%   39

How do I exclude these packages?

like image 411
Chris Williams Avatar asked Mar 30 '11 20:03

Chris Williams


People also ask

What does coverage mean in Python?

Code coverage is a metric for how much of your codebase gets executed when you run your tests. Basically, it tells you how much of your code is covered by tests and, more important, helps you locate lines in your code that aren't covered.

Which command is used to run nose tests?

Basic Usage nose can be integrated with DocTest by using with-doctest option in athe bove command line. The result will be true if the test run is successful, or false if it fails or raises an uncaught exception. nose supports fixtures (setup and teardown methods) at the package, module, class, and test level.


1 Answers

Try the nosetests --cover-package=<name> option. It will restrict coverage output to the listed packages/modules. You can use it more than once if your tests cover multiple packages.

like image 107
samplebias Avatar answered Nov 02 '22 04:11

samplebias