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 | 4c7da20cbb3dd516a367457cf17aa50598cd9094 (patch) | |
tree | 9b740a209d85f51a0daed44c1b4e68b11cfa008a /coverage/results.py | |
parent | 97fae250fffb33a7dfa0b2a5504d68fcdb26ed2f (diff) | |
download | python-coveragepy-4c7da20cbb3dd516a367457cf17aa50598cd9094.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 9df5d5b..1ca55e8 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 |