summaryrefslogtreecommitdiff
path: root/tests/test_results.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2017-03-08 06:43:57 -0500
committerNed Batchelder <ned@nedbatchelder.com>2017-03-08 06:43:57 -0500
commitc898faec0039f0761ac0c29bd8b4d3c0eb3f7575 (patch)
tree67f3f3d39b722080b8d3b367a133083c9f9c4023 /tests/test_results.py
parent2a672919cb758f04fd1857f313a3be5733c86298 (diff)
downloadpython-coveragepy-git-c898faec0039f0761ac0c29bd8b4d3c0eb3f7575.tar.gz
Give should_fail_under pure tests, so we don't need processes to test numeric comparisons
--HG-- extra : amend_source : 36d1fcdd986d1c2b4cd2af0d96d269e84fa40c2d
Diffstat (limited to 'tests/test_results.py')
-rw-r--r--tests/test_results.py25
1 files changed, 24 insertions, 1 deletions
diff --git a/tests/test_results.py b/tests/test_results.py
index c4d8ae5a..280694d0 100644
--- a/tests/test_results.py
+++ b/tests/test_results.py
@@ -3,7 +3,10 @@
"""Tests for coverage.py's results analysis."""
-from coverage.results import Numbers
+import pytest
+
+from coverage.results import Numbers, should_fail_under
+
from tests.coveragetest import CoverageTest
@@ -73,3 +76,23 @@ class NumbersTest(CoverageTest):
n_branches=10, n_missing_branches=3, n_partial_branches=1000,
)
self.assertEqual(n.ratio_covered, (160, 210))
+
+
+@pytest.mark.parametrize("total, fail_under, result", [
+ # fail_under==0 means anything is fine!
+ (0, 0, False),
+ (0.001, 0, False),
+ # very small fail_under is possible to fail.
+ (0.001, 0.01, True),
+ # Rounding should work properly.
+ (42.1, 42, False),
+ (42.1, 43, True),
+ (42.857, 42, False),
+ (42.857, 43, False),
+ (42.857, 44, True),
+ # Values near 100 should only be treated as 100 if they are 100.
+ (99.8, 100, True),
+ (100.0, 100, False),
+])
+def test_should_fail_under(total, fail_under, result):
+ assert should_fail_under(total, fail_under) == result