[TIP] coverage.py: Unexpected coverage report for library modules

Win Treese treese at acm.org
Mon Oct 25 18:43:46 PDT 2010


I can't figure out why I'm getting coverage reports for standard library modules with the (most excellent) coverage.py and (also most excellent) nose:

Python source:

% cat test.py
"""Demonstrate coverage of library module."""

import json

def test_json():
   print json.dumps({'a':3})


Run nose with coverage:

% nosetests --with-cover

.
Name                  Stmts   Miss  Cover   Missing
---------------------------------------------------
encodings.hex_codec      28     28     0%   9-71
json                     39     39     0%   100-323
json.decoder            216    216     0%   3-365
json.encoder            241    241     0%   3-442
json.scanner             52     52     0%   3-67
---------------------------------------------------
TOTAL                   576    576     0%   
----------------------------------------------------------------------
Ran 1 test in 0.012s

This is on Mac OS X 10.6.4 with:

$ python --version
Python 2.7
$ nosetests --version
nosetests version 0.11.4
$ coverage --version
Coverage.py, version 3.4.  http://nedbatchelder.com/code/coverage

From the documentation, I would expect those modules to be omitted. The coverage information is also incorrect, as if they are being reported, but not actually processed. I tried to trace it down through the code, but couldn't find the problem quickly.

Thanks for any help,

Win Treese
treese at acm.org






More information about the testing-in-python mailing list