diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2017-04-04 13:02:30 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2017-04-04 13:02:30 -0400 |
commit | da8c35c32433aeb8278de2ea25c7fbdb686e96ef (patch) | |
tree | 91edea01aa5a8f4e50ac3b48c977d32c389ef65a /coverage/xmlreport.py | |
parent | 4d1c9410becf12fc765b9184d33cd43023e66da4 (diff) | |
download | python-coveragepy-da8c35c32433aeb8278de2ea25c7fbdb686e96ef.tar.gz |
Use Cobertura v4 XML format. #570
Diffstat (limited to 'coverage/xmlreport.py')
-rw-r--r-- | coverage/xmlreport.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/coverage/xmlreport.py b/coverage/xmlreport.py index 694415f..8af0d78 100644 --- a/coverage/xmlreport.py +++ b/coverage/xmlreport.py @@ -18,11 +18,7 @@ from coverage.report import Reporter os = isolate_module(os) -DTD_URL = ( - 'https://raw.githubusercontent.com/cobertura/web/' - 'f0366e5e2cf18f111cbd61fc34ef720a6584ba02' - '/htdocs/xml/coverage-03.dtd' -) +DTD_URL = 'https://raw.githubusercontent.com/cobertura/web/master/htdocs/xml/coverage-04.dtd' def rate(hit, num): @@ -114,12 +110,18 @@ class XmlReporter(Reporter): bnum_tot += bnum bhits_tot += bhits + xcoverage.setAttribute("lines-valid", str(lnum_tot)) + xcoverage.setAttribute("lines-covered", str(lhits_tot)) xcoverage.setAttribute("line-rate", rate(lhits_tot, lnum_tot)) if self.has_arcs: - branch_rate = rate(bhits_tot, bnum_tot) + xcoverage.setAttribute("branches-valid", str(bnum_tot)) + xcoverage.setAttribute("branches-covered", str(bhits_tot)) + xcoverage.setAttribute("branch-rate", rate(bhits_tot, bnum_tot)) else: - branch_rate = "0" - xcoverage.setAttribute("branch-rate", branch_rate) + xcoverage.setAttribute("branches-covered", "0") + xcoverage.setAttribute("branches-valid", "0") + xcoverage.setAttribute("branch-rate", "0") + xcoverage.setAttribute("complexity", "0") # Use the DOM to write the output file. out = self.xml_out.toprettyxml() |