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:

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

      

I am running tests from a dir named backend:

project/backend$ python setup.py nosetests -s --tests=unit/test_setup.py

      

Nosetests is configured in the setup.cfg file as follows

[nosetests]
# locating tests
where=./test
include=^unit.*

# coverage
cover-package=lib
cover-html=1
cover-html-dir=htmlcov
with-xcoverage=1
xcoverage-file=coverage.xml
with-xunit=1
xunit-file=nosexunit.xml
cover-erase=1

      

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

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

+3


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

      

0


source







All Articles