How to properly limit package xcoverage coverage in nosetests using setup.cfg?

I configured it to skip my simple unit test. But nosexunit.xml reports test libs. Partial exit:

nosexcover-1.0.7-py2.6.egg/nosexcover/nosexcover    25     24     4%   5-41, 46-56
test/unit/test_setup                                13      0   100%   


The project is split into different modules that you need to test yourself. I am currently focusing on the backend module. I want to limit coverage to the lib package. Example project tree:

\-- backend     # <-- module I'm testing
    \-- lib     # <-- what I want to cover
    \-- test
       \-- unit/       # <-- test I'm running
    \-- setup.cfg
    \-- setup.cfg


I am running tests from a dir named backend:

project/backend$ python nosetests -s --tests=unit/


Nosetests is configured in the setup.cfg file as follows

# locating tests

# coverage


I have a feeling that one of the path settings is disabled. I am assuming that the settings where

and cover-package

are relative to the location

(also where I run the test) and is include

relative to where


The Nosetests documentation didn't help much. Hopefully someone can install me right here.


source to share

1 answer

It turns out that I did configure it correctly. The problem is that for my overly simplistic smoke test, I didn't actually import anything from the module to which I was limiting the coverage.

Apparently in this case, when the coverage is zero rather than reporting that boring fact, nosexcoverage or nosetests decides to give you a coverage report due to a bunch of other things.

By adding an import statement for the module I want, I got the corresponding coverage report:

XML: nosexunit.xml
Name        Stmts   Miss  Cover   Missing
lib             0      0   100%   
lib.blank       1      0   100%   
TOTAL           1      0   100%   
Ran 2 tests in 0.008s




All Articles