summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--coverage/cmdline.py3
-rw-r--r--coverage/results.py11
2 files changed, 8 insertions, 6 deletions
diff --git a/coverage/cmdline.py b/coverage/cmdline.py
index 97acdc42..5b15813e 100644
--- a/coverage/cmdline.py
+++ b/coverage/cmdline.py
@@ -523,7 +523,8 @@ class CoverageScript(object):
if options.fail_under is not None:
self.coverage.set_option("report:fail_under", options.fail_under)
- if should_fail_under(self.coverage, total):
+ fail_under = self.coverage.get_option("report:fail_under")
+ if should_fail_under(total, fail_under):
return FAIL_UNDER
return OK
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