(tag, expected, raw, compare=None)
| 8 | |
| 9 | |
| 10 | def check(tag, expected, raw, compare=None): |
| 11 | global nerrors |
| 12 | |
| 13 | if verbose: |
| 14 | print(" checking", tag) |
| 15 | |
| 16 | orig = raw[:] # save input in case of error |
| 17 | if compare: |
| 18 | raw.sort(key=cmp_to_key(compare)) |
| 19 | else: |
| 20 | raw.sort() |
| 21 | |
| 22 | if len(expected) != len(raw): |
| 23 | print("error in", tag) |
| 24 | print("length mismatch;", len(expected), len(raw)) |
| 25 | print(expected) |
| 26 | print(orig) |
| 27 | print(raw) |
| 28 | nerrors += 1 |
| 29 | return |
| 30 | |
| 31 | for i, good in enumerate(expected): |
| 32 | maybe = raw[i] |
| 33 | if good is not maybe: |
| 34 | print("error in", tag) |
| 35 | print("out of order at index", i, good, maybe) |
| 36 | print(expected) |
| 37 | print(orig) |
| 38 | print(raw) |
| 39 | nerrors += 1 |
| 40 | return |
| 41 | |
| 42 | class TestBase(unittest.TestCase): |
| 43 | def testStressfully(self): |
no test coverage detected
searching dependent graphs…