Issue #67 resolved

XML report: filenames may be generated incorrectly

Chris Adams
created an issue

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"> }}}

Comments (3)

  1. karlp

    This is also the sort of difference when using coverage from within nose vs running coverage xml after nose has generated the .coverage file.

  2. Log in to comment