Add a proper message to IncludedFeaNotFound

Also, minor f-string refactor.
This commit is contained in:
Nikolaus Waxweiler 2020-02-27 18:13:45 +00:00
parent 5025035f9e
commit 36c64087a8
2 changed files with 13 additions and 3 deletions

View File

@ -9,10 +9,18 @@ class FeatureLibError(Exception):
message = Exception.__str__(self)
if self.location:
path, line, column = self.location
return "%s:%d:%d: %s" % (path, line, column, message)
return f"{path}:{line}:{column}: {message}"
else:
return message
class IncludedFeaNotFound(FeatureLibError):
pass
def __str__(self):
assert self.location is not None
message = (
"The following feature file should be included but cannot be found: "
f"{Exception.__str__(self)}"
)
path, line, column = self.location
return f"{path}:{line}:{column}: {message}"

View File

@ -178,7 +178,9 @@ class IncludingLexerTest(unittest.TestCase):
def test_include_missing_file(self):
lexer = IncludingLexer(self.getpath("include/includemissingfile.fea"))
self.assertRaisesRegex(IncludedFeaNotFound,
"includemissingfile.fea:1:8: missingfile.fea",
"includemissingfile.fea:1:8: The following feature file "
"should be included but cannot be found: "
"missingfile.fea",
lambda: list(lexer))
def test_featurefilepath_None(self):