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
commita1e8886d2359d4f7bba91c1793670761ee5a5857 (patch)
treed76cffd6b8cc931387beecaa10a7ed16ce166090 /coverage/results.py
parent4d8445ea51236b91e7485eac1626d630d7bd7aae (diff)
downloadpython-coveragepy-a1e8886d2359d4f7bba91c1793670761ee5a5857.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 963ad8b..81ce2a6 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