diff options
-rw-r--r-- | CONTRIBUTORS.txt | 1 | ||||
-rw-r--r-- | coverage/results.py | 4 | ||||
-rw-r--r-- | tests/test_results.py | 5 |
3 files changed, 10 insertions, 0 deletions
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 4c07024c..93f27153 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -81,6 +81,7 @@ Matthew Desmarais Max Linke MichaĆ Bultrowicz Mickie Betz +Mike Fiedler Nathan Land Noel O'Boyle Olivier Grisel diff --git a/coverage/results.py b/coverage/results.py index cab8796e..9be16b15 100644 --- a/coverage/results.py +++ b/coverage/results.py @@ -283,6 +283,10 @@ def should_fail_under(total, fail_under, precision): Returns True if the total should fail. """ + # We can never achieve higher than 100% coverage + if fail_under > 100.0: + raise ValueError("`fail_under` is greater than 100. Please use 100 or lower.") + # Special case for fail_under=100, it must really be 100. if fail_under == 100.0 and total != 100.0: return True diff --git a/tests/test_results.py b/tests/test_results.py index 307ef762..f83b73dd 100644 --- a/tests/test_results.py +++ b/tests/test_results.py @@ -105,3 +105,8 @@ class NumbersTest(CoverageTest): ]) def test_should_fail_under(total, fail_under, precision, result): assert should_fail_under(float(total), float(fail_under), precision) == result + + +def test_should_fail_under_invalid_value(): + with pytest.raises(ValueError): + should_fail_under(100.0, 101, 0) |