diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2017-03-04 18:30:33 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2017-03-04 18:30:33 -0500 |
commit | 2b7324f3a0ed1e1b4dadec5941aa71636b0f46d3 (patch) | |
tree | ed65e32e8876f8410445d2a7522709f3c606d09d /coverage/results.py | |
parent | 7dfb4859633a215d584d14a4e11465492b4ac265 (diff) | |
download | python-coveragepy-git-2b7324f3a0ed1e1b4dadec5941aa71636b0f46d3.tar.gz |
Move the logic for fail-under to a testable function
Diffstat (limited to 'coverage/results.py')
-rw-r--r-- | coverage/results.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/coverage/results.py b/coverage/results.py index 9df5d5b2..1ca55e87 100644 --- a/coverage/results.py +++ b/coverage/results.py @@ -269,3 +269,23 @@ class Numbers(SimpleRepr): if other == 0: return self return NotImplemented + + +def should_fail_under(cov, total): + """Determine if a total should fail due to fail-under. + + Returns True if the total should fail. + + """ + if cov.get_option("report:fail_under"): + # Total needs to be rounded, but don't want to report 100 + # unless it is really 100. + if 99 < total < 100: + total = 99 + else: + total = round(total) + + if total < cov.get_option("report:fail_under"): + return True + + return False |