4 """Results of coverage measurement.""" |
4 """Results of coverage measurement.""" |
5 |
5 |
6 import collections |
6 import collections |
7 |
7 |
8 from coverage.debug import SimpleReprMixin |
8 from coverage.debug import SimpleReprMixin |
9 from coverage.exceptions import CoverageException |
9 from coverage.exceptions import ConfigError |
10 from coverage.misc import contract, nice_pair |
10 from coverage.misc import contract, nice_pair |
11 |
11 |
12 |
12 |
13 class Analysis: |
13 class Analysis: |
14 """The results of analyzing a FileReporter.""" |
14 """The results of analyzing a FileReporter.""" |
315 line_exits = sorted(arcs) |
315 line_exits = sorted(arcs) |
316 for line, exits in line_exits: |
316 for line, exits in line_exits: |
317 for ex in sorted(exits): |
317 for ex in sorted(exits): |
318 if line not in lines and ex not in lines: |
318 if line not in lines and ex not in lines: |
319 dest = (ex if ex > 0 else "exit") |
319 dest = (ex if ex > 0 else "exit") |
320 line_items.append((line, "%d->%s" % (line, dest))) |
320 line_items.append((line, f"{line}->{dest}")) |
321 |
321 |
322 ret = ', '.join(t[-1] for t in sorted(line_items)) |
322 ret = ', '.join(t[-1] for t in sorted(line_items)) |
323 return ret |
323 return ret |
324 |
324 |
325 |
325 |
335 |
335 |
336 """ |
336 """ |
337 # We can never achieve higher than 100% coverage, or less than zero. |
337 # We can never achieve higher than 100% coverage, or less than zero. |
338 if not (0 <= fail_under <= 100.0): |
338 if not (0 <= fail_under <= 100.0): |
339 msg = f"fail_under={fail_under} is invalid. Must be between 0 and 100." |
339 msg = f"fail_under={fail_under} is invalid. Must be between 0 and 100." |
340 raise CoverageException(msg) |
340 raise ConfigError(msg) |
341 |
341 |
342 # Special case for fail_under=100, it must really be 100. |
342 # Special case for fail_under=100, it must really be 100. |
343 if fail_under == 100.0 and total != 100.0: |
343 if fail_under == 100.0 and total != 100.0: |
344 return True |
344 return True |
345 |
345 |