2

I'm using nosetests and the coverage extension to measure the coverage of my unit tests.

I've recently moved to including the six module with my package to make it easier for users.

The problem is that having six locally seems to mess up the coverage report.

I run my tests like this:

nosetests --cover-erase --with-coverage --cover-html --cover-package seaborn

The report ends up including references to files that aren't in my directory tree:

Name                    Stmts   Miss  Cover   Missing
-----------------------------------------------------
ConfigParser              391    391     0%   90-753
HTMLParser                306    306     0%   11-472
Queue                     125    125     0%   3-244
copy_reg                  105    105     0%   7-188
htmlentitydefs              9      9     0%   4-273
httplib                   704    704     0%   69-1342
repr                      103    103     0%   3-132
seaborn                     9      0   100%
<...>

The reason I think six is causing the problem is that when I search for those names, they only appear in six.py:

$ git grep ConfigParser
seaborn/external/six.py:    MovedModule("configparser", "ConfigParser"),

$ git grep copy_reg
seaborn/external/six.py:    MovedModule("copyreg", "copy_reg"),

At no point in my code do I import * from six, all of my imports are specific, like from .external.six.moves import range

How can I exclude these objects/files from the coverage report?

I've tried adding omit = seaborn/external to my .coveragerc (under [run]), and that excludes the files in seaborn/external from the report, but not the names that six seems to be defining.

mwaskom
  • 46,693
  • 16
  • 125
  • 127
  • Whatever magic six uses to add aliases for the moved modules, it appears to be tricking coverage into thinking these modules are imported and are not part of the standard library (which is excluded by default). –  Mar 10 '14 at 21:55
  • Have you tried running nose with `--cover-inclusive`? – Drewness Mar 10 '14 at 21:55
  • `--cover-inclusive` seems not to solve the problem (but does trigger some test errors, weirdly) – mwaskom Mar 10 '14 at 21:59

1 Answers1

0

Put this into your .coveragerc instead.

[run]
include = seaborn/*

Documentation for configuration - http://nedbatchelder.com/code/coverage/config.html#config

metatoaster
  • 17,419
  • 5
  • 55
  • 66
  • This does seem to work. Do you have a pointer to something I could read that would explain why? – mwaskom Mar 10 '14 at 23:01