diff options
author | John MacFarlane <jgm@berkeley.edu> | 2017-11-05 10:20:12 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2017-11-05 10:20:12 -0800 |
commit | cb27409921300ad5ea6ccc5e29d3c78d2ed048b3 (patch) | |
tree | 79f42f00a7a2b26d90e529aa112301c0ee318eae /test/pathological_tests.py | |
parent | ed990f56553f4c144c57cdff85aaa1c437ba8be2 (diff) |
Refactored pathological_tests.py
Diffstat (limited to 'test/pathological_tests.py')
-rw-r--r-- | test/pathological_tests.py | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/test/pathological_tests.py b/test/pathological_tests.py index 6883c10..dd80092 100644 --- a/test/pathological_tests.py +++ b/test/pathological_tests.py @@ -71,28 +71,32 @@ pathological = { } whitespace_re = re.compile('/s+/') -passed = 0 -errored = 0 -failed = 0 -print("Testing pathological cases:") -for description in pathological: +results = {'passed': 0, 'errored': 0, 'failed': 0} + +def run_pathological_test(description, results): (inp, regex) = pathological[description] [rc, actual, err] = cmark.to_html(inp) if rc != 0: - errored += 1 print(description, '[ERRORED (return code %d)]' %rc) print(err) + results['errored'] += 1 elif regex.search(actual): print(description, '[PASSED]') - passed += 1 + results['passed'] += 1 else: print(description, '[FAILED]') print(repr(actual)) - failed += 1 + results['failed'] += 1 + + +print("Testing pathological cases:") +for description in pathological: + run_pathological_test(description, results) -print("%d passed, %d failed, %d errored" % (passed, failed, errored)) -if (failed == 0 and errored == 0): +print("%d passed, %d failed, %d errored" % + (results['passed'], results['failed'], results['errored'])) +if (results['failed'] == 0 and results['errored'] == 0): exit(0) else: exit(1) |