Report syntax errors as unhandled exceptions

Update tests accordingly
This commit is contained in:
George Edward Bulmer 2018-02-12 14:07:05 +00:00
parent ce8b457bac
commit b59a7cdcc0
2 changed files with 2 additions and 2 deletions

View File

@ -419,7 +419,7 @@ def read_config_py(filename, raising=False):
desc = configexc.ConfigErrorDesc("Error while compiling", e)
raise configexc.ConfigFileErrors(basename, [desc])
except SyntaxError as e:
desc = configexc.ConfigErrorDesc("Syntax Error", e,
desc = configexc.ConfigErrorDesc("Unhandled exception", e,
traceback=traceback.format_exc())
raise configexc.ConfigFileErrors(basename, [desc])

View File

@ -550,7 +550,7 @@ class TestConfigPy:
assert len(excinfo.value.errors) == 1
error = excinfo.value.errors[0]
assert isinstance(error.exception, SyntaxError)
assert error.text == "Syntax Error"
assert error.text == "Unhandled exception"
exception_text = 'invalid syntax (config.py, line 1)'
assert str(error.exception) == exception_text