[TIP] Question about nosetests coverage output

Ned Batchelder ned at nedbatchelder.com
Wed Jan 6 09:23:45 PST 2016

On 1/6/16 11:17 AM, Fred Drake wrote:
> I've been using nosetests --with-coverage with setuptools projects
> recently, and have noticed something a little odd.
> In one repository, I've a project with several Python packages in
> separate directories, each with their own setup.py.  The HTML coverage
> reports for these list the covered modules with their dotted names;
> the __init__ files are listed with their __name__, as expected.
> In another repository with a single Python package hierarchy, running
> nosetests --with-coverage produces and HTML report file names with the
> .py extension stripped off, but using slashes and explicit __init__.
> I'm using Python 2.7, coverage 3.7.1, and nose 1.3.1, all from stock
> packages provided for Ubuntu 14.04.3.

It sounds like the second repo is using coverage.py 4.0.x.  Reports in 
3.7 used module-style names (dots, no extension).  4.0 uses file-style 
names (slashes, with extensions).  This was done because 4.0 supports 
reporting on non-Python files, such as Django template files.

The HTML report has the version of coverage in the footer.  You can 
check there for sure what version is being used for each repo.

> Any ideas why these's a difference in these reports?  It's not really
> significant, but it's a little disturbing just because I don't
> understand.
>    -Fred

More information about the testing-in-python mailing list