[TIP] Coverage weirdness with nose

Ned Batchelder ned at nedbatchelder.com
Mon Jan 16 13:50:58 PST 2012


On 1/16/2012 2:11 PM, Chris Withers wrote:
>
> Having some truly weird behaviour with coverage and the tests for my 
> testfixtures package.
>
> When I run the tests as follows:
>
> $ bin/nosetests --with-xcoverage --xcoverage-file=$PWD/coverage.xml
>
> ...I get plenty of coverage output, but none of it is for the 
> testfixtures package itself, even though all its tests run successfully.
>
> If I run as follows:
>
> $ bin/nosetests --with-xcoverage --xcoverage-file=$PWD/coverage.xml 
> --cover-package=testfixtures
>
> ...I get the output in the PS of this mail.
>
> Problems appear to be:
>
> - coverage info is still being reported for the manuel, nose, 
> nose_fixes, nosexcover, zope.component, zope.event and zope.interface 
> packages. Why is that?
>
> - coverage info is being collected for the tests folder of the 
> testfixtures package, which just contains the unit tests. How do I 
> tell coverage-via-nose not to include anything in testfixtures.tests?
>
> - because of the above, there's lots of problems with python examples 
> in doctests run by manuel not having any source. One of these appears 
> to blow up the report generation, which seems unintentional?
>
> Any help gratefully appreciated!
Chris, to tell you the truth, I don't know how the nose coverage plugin 
works, and therefore I recommend people not use it.  I use coverage to 
run the test runner, instead of the other way around.  Even if you do 
use nose to drive coverage, you're better off using the .coveragerc file 
to control the reporting.  The source option is great for controlling 
coverage's attention.

--Ned.



More information about the testing-in-python mailing list