XML report: filenames may be generated incorrectly · Issue #67 · nedbat/coveragepy (original) (raw)

Originally reported by Chris Adams (Bitbucket: acdha, GitHub: acdha)


I ran into an odd problem using the coverage XML report on our Hudson CI server. It turns out that the xml report will generate inconsistent filenames based on the configuration.

If you call xml_report with a list of module names (e.g. "proj.submod") like this:

#!python

    cov.xml_report(
        coverage_modules
        outfile=os.path.join(options.output_dir, "coverage.xml"),
    )

the XML will be generated with module names in the filename attribute:

<class branch-rate="0.3125" complexity="0.0" filename="bin.test-coverage" line-rate="0.415841584158" name="test-coverage">

If you instead filter the report using something like include/omit_prefixes:

#!python

    cov.xml_report(
        outfile=os.path.join(options.output_dir, "coverage.xml"),
        include_prefixes=[PROJECT_ROOT], 
        omit_prefixes=[os.path.join(PROJECT_ROOT, "proto", "templates")]
    )

the XML will have real filesystem paths in the filename attribute:

<class branch-rate="0.3125" complexity="0.0" filename="bin/test-coverage.py" line-rate="0.415841584158" name="test-coverage">