tests: Exclude lines from coverage

Exclude things like "raise NotImplementedError" and compiler bug
handlers.
This commit is contained in:
James Westman 2022-01-13 00:02:41 -06:00
parent 85150d397b
commit 1897478480
No known key found for this signature in database
GPG key ID: CE2DBA0ADB654EA6
4 changed files with 15 additions and 12 deletions

View file

@ -46,11 +46,11 @@ class TestSamples(unittest.TestCase):
raise MultipleErrors(ast.errors)
actual = ast.generate()
if actual.strip() != expected.strip():
if actual.strip() != expected.strip(): # pragma: no cover
diff = difflib.unified_diff(expected.splitlines(), actual.splitlines())
print("\n".join(diff))
raise AssertionError()
except PrintableError as e:
except PrintableError as e: # pragma: no cover
e.pretty_print(name + ".blp", blueprint)
raise AssertionError()
@ -79,14 +79,14 @@ class TestSamples(unittest.TestCase):
actual = error_str(e)
elif isinstance(e, MultipleErrors):
actual = "\n".join([error_str(error) for error in e.errors])
else:
else: # pragma: no cover
raise AssertionError()
if actual.strip() != expected.strip():
if actual.strip() != expected.strip(): # pragma: no cover
diff = difflib.unified_diff(expected.splitlines(), actual.splitlines())
print("\n".join(diff))
raise AssertionError()
else:
else: # pragma: no cover
# Expected a compiler error but there wasn't one
raise AssertionError()
@ -101,11 +101,11 @@ class TestSamples(unittest.TestCase):
actual = decompiler.decompile(ui_path)
if actual.strip() != expected.strip():
if actual.strip() != expected.strip(): # pragma: no cover
diff = difflib.unified_diff(expected.splitlines(), actual.splitlines())
print("\n".join(diff))
raise AssertionError()
except PrintableError as e:
except PrintableError as e: # pragma: no cover
e.pretty_print(name + ".blp", blueprint)
raise AssertionError()