question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incomplete file path in XML report

See original GitHub issue

Originally reported by Anonymous


Hi there, we are relying on the XML coverage report generated in coverage.xml for our analysis.

In previous versions of coverage, when we run the command such as:

$ py.test --cov directory_one --cov directory_two --cov-report xml tests

We would get a coverage.xml file with sources listed as:

<sources>
	<source>/path/to/directory_one</source>
	<source>/path/to/directory_two</source>
</sources>

And each file would be reported in a line such as this:

<class branch-rate="0" complexity="0" filename="directory_one/__init__.py" line-rate="1" name="__init__.py">

Now in coverage 4.4 the first level of the directory path is missing and we get only:

<class branch-rate="0" complexity="0" filename="__init__.py" line-rate="1" name="__init__.py">

Is there any way to get the previous behaviour?


Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:35 (31 by maintainers)

github_iconTop GitHub Comments

6reactions
jacobwegnercommented, Aug 17, 2018

@nedbat I ran across this issue and believe I’ve found a useful workaround.

https://bitbucket.org/suriya/coverage-xml-bug/pull-requests/1/demonstrate-a-fix-to-coverage-xml-bug/diff

Changing from specifying the modules in [sources] to directory paths in [include] ensures that the path to each file is output in coverage.xml:

using [source]:

<class branch-rate="0" complexity="0" filename="hello.py" line-rate="1" name="hello.py">
<class branch-rate="0" complexity="0" filename="baz/hello.py" line-rate="1" name="hello.py">

using [include]:

<class branch-rate="0" complexity="0" filename="bar/hello.py" line-rate="1" name="hello.py">
<class branch-rate="0" complexity="0" filename="bar/baz/hello.py" line-rate="1" name="hello.py">
<class branch-rate="0" complexity="0" filename="foo/hello.py" line-rate="1" name="hello.py">

I’m not sure how this might need to be worded in the project’s documentation, but will try and take a stab at it if you think that’d be useful.

2reactions
drazisilcommented, Aug 5, 2019

I spent the weekend going crazy with pytest-cov and Codecov.

I can confirm that Codecov walks the filename= tags and without a path in them there is not way for it to match the coverage to a file.

FYI, the generated coverage.xml file says it uses https://raw.githubusercontent.com/cobertura/web/master/htdocs/xml/coverage-04.dtd, if that helps any, @blueyed (It’s very bare bones)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Checkstyle generate incompleted XML report - Stack Overflow
I run Checkstyle with Ant. Some projects work correctly, however, there's one project with very strange result. The XML report is not completed, ......
Read more >
BI Publisher generates incomplete xml output files for huge data
While running scheduled jobs with xml as output format and SFTP as delivery, BIP is generating and writing the file at specified location....
Read more >
Understanding schema errors | HESA
The schema describes the structure of the XML document (number of elements, whether an element can be empty, default/fixed values, etc.) and valid...
Read more >
Fixing-Your-XML-Error.pdf - IRS
This Document will assist you with resolving your XML schema validation ... In this example, look at the W2s for the missing or...
Read more >
Import XML data - Microsoft Support
The XML file you're trying to open doesn't refer to an XML schema. To work with the XML data that's in the file,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found