Add a proper message to IncludedFeaNotFound
Also, minor f-string refactor.
This commit is contained in:
parent
5025035f9e
commit
36c64087a8
@ -9,10 +9,18 @@ class FeatureLibError(Exception):
|
|||||||
message = Exception.__str__(self)
|
message = Exception.__str__(self)
|
||||||
if self.location:
|
if self.location:
|
||||||
path, line, column = self.location
|
path, line, column = self.location
|
||||||
return "%s:%d:%d: %s" % (path, line, column, message)
|
return f"{path}:{line}:{column}: {message}"
|
||||||
else:
|
else:
|
||||||
return message
|
return message
|
||||||
|
|
||||||
|
|
||||||
class IncludedFeaNotFound(FeatureLibError):
|
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}"
|
||||||
|
@ -178,7 +178,9 @@ class IncludingLexerTest(unittest.TestCase):
|
|||||||
def test_include_missing_file(self):
|
def test_include_missing_file(self):
|
||||||
lexer = IncludingLexer(self.getpath("include/includemissingfile.fea"))
|
lexer = IncludingLexer(self.getpath("include/includemissingfile.fea"))
|
||||||
self.assertRaisesRegex(IncludedFeaNotFound,
|
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))
|
lambda: list(lexer))
|
||||||
|
|
||||||
def test_featurefilepath_None(self):
|
def test_featurefilepath_None(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user