summaryrefslogtreecommitdiff
path: root/tests/test_results.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2021-05-31 19:37:53 -0400
committerNed Batchelder <ned@nedbatchelder.com>2021-05-31 19:37:53 -0400
commit1157999dc5c6c3aa3129a7cd4bf249fe73598501 (patch)
treecba407bacb180fb8fcb46a1b5eaf7da2e0fd88fb /tests/test_results.py
parent65d9e0edbca0dc893ca70fbf64969e2ddc5a3680 (diff)
downloadpython-coveragepy-git-1157999dc5c6c3aa3129a7cd4bf249fe73598501.tar.gz
fix: --fail-under=100 could report 100 is less than 100.
Use the same rounding rules for the fail-under message that are used for totals everywhere else, so that it won't say: total of 100 is less than fail-under=100
Diffstat (limited to 'tests/test_results.py')
-rw-r--r--tests/test_results.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/test_results.py b/tests/test_results.py
index 5811b0c2..fa239e92 100644
--- a/tests/test_results.py
+++ b/tests/test_results.py
@@ -68,6 +68,18 @@ class NumbersTest(CoverageTest):
assert n10000.pc_covered_str == "0.0"
Numbers.set_precision(0)
+ @pytest.mark.parametrize("prec, pc, res", [
+ (0, 47.87, "48"),
+ (1, 47.87, "47.9"),
+ (0, 99.995, "99"),
+ (2, 99.99995, "99.99"),
+ ])
+ def test_display_covered(self, prec, pc, res):
+ # Numbers._precision is a global, which is bad.
+ Numbers.set_precision(prec)
+ assert Numbers.display_covered(pc) == res
+ Numbers.set_precision(0)
+
def test_covered_ratio(self):
n = Numbers(n_files=1, n_statements=200, n_missing=47)
assert n.ratio_covered == (153, 200)