summaryrefslogtreecommitdiff
path: root/coverage/results.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2017-03-08 06:41:59 -0500
committerNed Batchelder <ned@nedbatchelder.com>2017-03-08 06:41:59 -0500
commit2a672919cb758f04fd1857f313a3be5733c86298 (patch)
treeee43fe76c09e8a26184a3a13a1ebbb1a1a292725 /coverage/results.py
parent62a9177ce9f615bbfd46e8d01246977cf9091de2 (diff)
downloadpython-coveragepy-git-2a672919cb758f04fd1857f313a3be5733c86298.tar.gz
Make should_fail_under an even more pure function.
Diffstat (limited to 'coverage/results.py')
-rw-r--r--coverage/results.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/coverage/results.py b/coverage/results.py
index 963ad8b3..81ce2a68 100644
--- a/coverage/results.py
+++ b/coverage/results.py
@@ -271,16 +271,17 @@ class Numbers(SimpleRepr):
return NotImplemented
-def should_fail_under(cov, total):
+def should_fail_under(total, fail_under):
"""Determine if a total should fail due to fail-under.
- `cov` is a Coverage instance, `total` is a float, the coverage measurement
- total.
+ `total` is a float, the coverage measurement total. `fail_under` is the
+ fail_under setting to compare with.
Returns True if the total should fail.
"""
- if cov.get_option("report:fail_under"):
+ # The fail_under option defaults to 0.
+ if fail_under:
# Total needs to be rounded, but don't want to report 100
# unless it is really 100.
if 99 < total < 100:
@@ -288,7 +289,7 @@ def should_fail_under(cov, total):
else:
total = round(total)
- if total < cov.get_option("report:fail_under"):
+ if total < fail_under:
return True
return False