summaryrefslogtreecommitdiff
path: root/coverage
diff options
context:
space:
mode:
Diffstat (limited to 'coverage')
-rw-r--r--coverage/control.py4
-rw-r--r--coverage/data.py5
-rw-r--r--coverage/html.py23
-rw-r--r--coverage/htmlfiles/index.html9
-rw-r--r--coverage/htmlfiles/pyfile.html4
-rw-r--r--coverage/htmlfiles/style.css4
6 files changed, 37 insertions, 12 deletions
diff --git a/coverage/control.py b/coverage/control.py
index 3861cc19..c08fda62 100644
--- a/coverage/control.py
+++ b/coverage/control.py
@@ -382,6 +382,10 @@ class Analysis(object):
pc_cov = 100.0
return pc_cov
+ def has_arcs(self):
+ """Were arcs measured in this result?"""
+ return self.coverage.data.has_arcs()
+
def arc_possibilities(self):
"""Returns a sorted list of the arcs in the code."""
return self.parser.arcs()
diff --git a/coverage/data.py b/coverage/data.py
index a4bc6086..72ce38fd 100644
--- a/coverage/data.py
+++ b/coverage/data.py
@@ -219,6 +219,11 @@ class CoverageData(object):
summ[filename_fn(filename)] = len(lines)
return summ
+ def has_arcs(self):
+ """Does this data have arcs?"""
+ return bool(self.arcs)
+
+
if __name__ == '__main__':
# Ad-hoc: show the raw data in a data file.
import pprint, sys
diff --git a/coverage/html.py b/coverage/html.py
index df7bc03c..59bc995e 100644
--- a/coverage/html.py
+++ b/coverage/html.py
@@ -55,6 +55,7 @@ class HtmlReporter(Reporter):
self.source_tmpl = Templite(data("htmlfiles/pyfile.html"), globals())
self.files = []
+ self.arcs = coverage.data.has_arcs()
def report(self, morfs, directory, omit_prefixes=None):
"""Generate an HTML report for `morfs`.
@@ -95,11 +96,12 @@ class HtmlReporter(Reporter):
pc_cov = analysis.percent_covered()
missing_branch_arcs = analysis.missing_branch_arcs()
- n_par = len(missing_branch_arcs)
+ n_par = 0 # accumulated below.
+ arcs = self.arcs
# These classes determine which lines are highlighted by default.
c_run = " run hide"
- c_exc = " exc"
+ c_exc = " exc hide"
c_mis = " mis"
c_par = " par"
@@ -117,16 +119,16 @@ class HtmlReporter(Reporter):
line_class = ""
if lineno in analysis.statements:
line_class += " stm"
- if lineno not in analysis.missing and \
- lineno not in analysis.excluded:
- line_class += c_run
if lineno in analysis.excluded:
line_class += c_exc
- if lineno in analysis.missing:
+ elif lineno in analysis.missing:
line_class += c_mis
- if lineno in missing_branch_arcs:
+ elif self.arcs and lineno in missing_branch_arcs:
line_class += c_par
-
+ n_par += 1
+ elif lineno in analysis.statements:
+ line_class += c_run
+
lineinfo = {
'html': "".join(line),
'number': lineno,
@@ -172,6 +174,7 @@ class HtmlReporter(Reporter):
'run': n_run,
'exc': n_exc,
'mis': n_mis,
+ 'par': n_par,
'pc_cov': pc_cov,
'html_filename': html_filename,
'cu': cu,
@@ -182,10 +185,12 @@ class HtmlReporter(Reporter):
index_tmpl = Templite(data("htmlfiles/index.html"), globals())
files = self.files
-
+ arcs = self.arcs
+
total_stm = sum([f['stm'] for f in files])
total_run = sum([f['run'] for f in files])
total_exc = sum([f['exc'] for f in files])
+ total_par = sum([f['par'] for f in files])
if total_stm:
total_cov = 100.0 * total_run / total_stm
else:
diff --git a/coverage/htmlfiles/index.html b/coverage/htmlfiles/index.html
index 35659317..2234ac73 100644
--- a/coverage/htmlfiles/index.html
+++ b/coverage/htmlfiles/index.html
@@ -21,6 +21,9 @@
<th>statements</th>
<th>run</th>
<th>excluded</th>
+ {% if arcs %}
+ <th>partial</th>
+ {% endif %}
<th>coverage</th>
</tr>
{% for file in files %}
@@ -29,6 +32,9 @@
<td>{{file.stm}}</td>
<td>{{file.run}}</td>
<td>{{file.exc}}</td>
+ {% if arcs %}
+ <td>{{file.par}}</td>
+ {% endif %}
<td>{{file.pc_cov|format_pct}}%</td>
</tr>
{% endfor %}
@@ -37,6 +43,9 @@
<td>{{total_stm}}</td>
<td>{{total_run}}</td>
<td>{{total_exc}}</td>
+{% if arcs %}
+<td>{{total_par}}</td>
+{% endif %}
<td>{{total_cov|format_pct}}%</td>
</tr>
</table>
diff --git a/coverage/htmlfiles/pyfile.html b/coverage/htmlfiles/pyfile.html
index 8a0dd4e9..91c56cbe 100644
--- a/coverage/htmlfiles/pyfile.html
+++ b/coverage/htmlfiles/pyfile.html
@@ -29,7 +29,9 @@ function toggle_lines(btn, cls) {
<span class='{{c_run.strip}}' onclick='toggle_lines(this, "run")'>{{n_run}} run</span>
<span class='{{c_exc.strip}}' onclick='toggle_lines(this, "exc")'>{{n_exc}} excluded</span>
<span class='{{c_mis.strip}}' onclick='toggle_lines(this, "mis")'>{{n_mis}} missing</span>
- <span class='{{c_par.strip}}' onclick='toggle_lines(this, "par")'>{{n_par}} partial</span>
+ {% if arcs %}
+ <span class='{{c_par.strip}}' onclick='toggle_lines(this, "par")'>{{n_par}} partial</span>
+ {% endif %}
</h2>
</div>
</div>
diff --git a/coverage/htmlfiles/style.css b/coverage/htmlfiles/style.css
index b55e4992..48961e53 100644
--- a/coverage/htmlfiles/style.css
+++ b/coverage/htmlfiles/style.css
@@ -126,8 +126,8 @@ td.text {
border-left: 2px solid #808080;
}
.text p.par {
- background: #ffffdd;
- border-left: 2px solid #ffff00;
+ background: #ffffaa;
+ border-left: 2px solid #eeee99;
}
.text p.hide {
background: inherit;