summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2015-07-22 08:44:58 -0400
committerNed Batchelder <ned@nedbatchelder.com>2015-07-22 08:44:58 -0400
commit9266eebcd681ec38f118fe018a154acb5f1c67ae (patch)
treebf8c037b55e8001aa90d888676a6602aba10c03e
parent39f5c4cb7692a0884ea9c14e6dd677c98230096f (diff)
downloadpython-coveragepy-git-9266eebcd681ec38f118fe018a154acb5f1c67ae.tar.gz
Add an attribute to the XML report for missed branches
-rw-r--r--AUTHORS.txt1
-rw-r--r--coverage/xmlreport.py4
-rw-r--r--tests/farm/html/gold_y_xml_branch/coverage.xml2
3 files changed, 6 insertions, 1 deletions
diff --git a/AUTHORS.txt b/AUTHORS.txt
index 022342c5..7db5d1c2 100644
--- a/AUTHORS.txt
+++ b/AUTHORS.txt
@@ -59,6 +59,7 @@ Sigve Tjora
Stan Hu
Stefan Behnel
Steve Leonard
+Steve Peak
Ted Wexler
Titus Brown
Zooko Wilcox-O'Hearn
diff --git a/coverage/xmlreport.py b/coverage/xmlreport.py
index 5f16bc4f..0df449f3 100644
--- a/coverage/xmlreport.py
+++ b/coverage/xmlreport.py
@@ -147,6 +147,7 @@ class XmlReporter(Reporter):
xclass.setAttribute("complexity", "0")
branch_stats = analysis.branch_stats()
+ missing_branch_arcs = analysis.missing_branch_arcs()
# For each statement, create an XML 'line' element.
for line in sorted(analysis.statements):
@@ -165,6 +166,9 @@ class XmlReporter(Reporter):
"condition-coverage",
"%d%% (%d/%d)" % (100*taken/total, taken, total)
)
+ if line in missing_branch_arcs:
+ annlines = ["exit" if b < 0 else str(b) for b in missing_branch_arcs[line]]
+ xline.setAttribute("missing-branches", ",".join(annlines))
xlines.appendChild(xline)
class_lines = len(analysis.statements)
diff --git a/tests/farm/html/gold_y_xml_branch/coverage.xml b/tests/farm/html/gold_y_xml_branch/coverage.xml
index 9d3e37fc..63625b28 100644
--- a/tests/farm/html/gold_y_xml_branch/coverage.xml
+++ b/tests/farm/html/gold_y_xml_branch/coverage.xml
@@ -13,7 +13,7 @@
<methods/>
<lines>
<line hits="1" number="3"/>
- <line branch="true" condition-coverage="50% (1/2)" hits="1" number="4"/>
+ <line branch="true" condition-coverage="50% (1/2)" hits="1" missing-branches="7" number="4"/>
<line hits="1" number="5"/>
<line hits="0" number="7"/>
<line hits="1" number="9"/>