diff -r bedab77d0fa3 -r d6c795b5ce33 DebugClients/Python/coverage/results.py --- a/DebugClients/Python/coverage/results.py Sat Apr 07 13:17:06 2018 +0200 +++ b/DebugClients/Python/coverage/results.py Sat Apr 07 13:35:10 2018 +0200 @@ -6,7 +6,7 @@ import collections from coverage.backward import iitems -from coverage.misc import format_lines +from coverage.misc import contract, format_lines, SimpleRepr class Analysis(object): @@ -157,7 +157,7 @@ return stats -class Numbers(object): +class Numbers(SimpleRepr): """The numerical results of measuring coverage. This holds the basic statistics from `Analysis`, and is used to roll @@ -269,3 +269,21 @@ if other == 0: return self return NotImplemented + + +@contract(total='number', fail_under='number', precision=int, returns=bool) +def should_fail_under(total, fail_under, precision): + """Determine if a total should fail due to fail-under. + + `total` is a float, the coverage measurement total. `fail_under` is the + fail_under setting to compare with. `precision` is the number of digits + to consider after the decimal point. + + Returns True if the total should fail. + + """ + # Special case for fail_under=100, it must really be 100. + if fail_under == 100.0 and total != 100.0: + return True + + return round(total, precision) < fail_under