From 94bf5f731aa8addcedb162525e96c4e1bd2ebfdd Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 22 Aug 2010 23:18:14 -0400 Subject: Unify formatting of coverage percentages, and don't show zero or 100 as a result of rounding. Fixes #41 and #70. --- coverage/html.py | 4 ---- coverage/htmlfiles/index.html | 6 +++--- coverage/htmlfiles/pyfile.html | 4 ++-- coverage/results.py | 17 +++++++++++++++++ coverage/summary.py | 6 +++--- 5 files changed, 25 insertions(+), 12 deletions(-) (limited to 'coverage') diff --git a/coverage/html.py b/coverage/html.py index fc6d8016..9ca4dea0 100644 --- a/coverage/html.py +++ b/coverage/html.py @@ -174,10 +174,6 @@ def escape(t): .replace(" ", "  ") ) -def format_pct(p): - """Format `p` as a percentage value for the HTML reports.""" - return "%.0f" % p - def spaceless(html): """Squeeze out some annoying extra space from an HTML string. diff --git a/coverage/htmlfiles/index.html b/coverage/htmlfiles/index.html index c1ef8ad7..bec2584f 100644 --- a/coverage/htmlfiles/index.html +++ b/coverage/htmlfiles/index.html @@ -16,7 +16,7 @@ @@ -48,7 +48,7 @@ {{totals.n_branches}} {{totals.n_missing_branches}} {% endif %} - {{totals.pc_covered|format_pct}}% + {{totals.pc_covered_str}}% @@ -62,7 +62,7 @@ {{file.nums.n_branches}} {{file.nums.n_missing_branches}} {% endif %} - {{file.nums.pc_covered|format_pct}}% + {{file.nums.pc_covered_str}}% {% endfor %} diff --git a/coverage/htmlfiles/pyfile.html b/coverage/htmlfiles/pyfile.html index 035691c8..05b2b464 100644 --- a/coverage/htmlfiles/pyfile.html +++ b/coverage/htmlfiles/pyfile.html @@ -5,7 +5,7 @@ {# IE8 rounds line-height incorrectly, and adding this emulateIE7 line makes it right! #} {# http://social.msdn.microsoft.com/Forums/en-US/iewebdevelopment/thread/7684445e-f080-4d8f-8529-132763348e21 #} - Coverage for {{cu.name|escape}}: {{nums.pc_covered|format_pct}}% + Coverage for {{cu.name|escape}}: {{nums.pc_covered_str}}% @@ -18,7 +18,7 @@