Final changes to follow vagueries

This commit is contained in:
Martin Hosken 2017-03-08 16:54:11 +00:00
parent 2972d81d82
commit 5906b5358a
3 changed files with 19 additions and 17 deletions

View File

@ -200,7 +200,7 @@ class IncludingLexer(object):
while self.lexers_:
lexer = self.lexers_[-1]
try:
token_type, token, location = lexer.next()
token_type, token, location = next(lexer)
except StopIteration:
self.lexers_.pop()
continue

View File

@ -1375,7 +1375,7 @@ class Parser(object):
while True:
try:
(self.next_token_type_, self.next_token_,
self.next_token_location_) = self.lexer_.next()
self.next_token_location_) = next(self.lexer_)
except StopIteration:
self.next_token_type_, self.next_token_ = (None, None)
if self.next_token_type_ != Lexer.COMMENT:

View File

@ -140,23 +140,25 @@ class BuilderTest(unittest.TestCase):
fname = (name + ".fea") if '.' not in name else name
temp = parser.ignore_comments
parser.ignore_comments = False
p = parser(self.getpath(fname), glyphMap=font.getReverseGlyphMap())
doc = p.parse()
actual = self.normal_fea(doc.asFea().split("\n"))
try:
p = parser(self.getpath(fname), glyphMap=font.getReverseGlyphMap())
doc = p.parse()
actual = self.normal_fea(doc.asFea().split("\n"))
with open(self.getpath(base or fname), "r", encoding="utf-8") as ofile:
expected = self.normal_fea(ofile.readlines())
with open(self.getpath(base or fname), "r", encoding="utf-8") as ofile:
expected = self.normal_fea(ofile.readlines())
if expected != actual:
fname = name.rsplit(".", 1)[0] + ".fea"
for line in difflib.unified_diff(
expected, actual,
fromfile=fname + " (expected)",
tofile=fname + " (actual)"):
sys.stderr.write(line+"\n")
self.fail("Fea2Fea output is different from expected. "
"Generated:\n{}\n".format("\n".join(actual)))
parser.ignore_comments = temp
if expected != actual:
fname = name.rsplit(".", 1)[0] + ".fea"
for line in difflib.unified_diff(
expected, actual,
fromfile=fname + " (expected)",
tofile=fname + " (actual)"):
sys.stderr.write(line+"\n")
self.fail("Fea2Fea output is different from expected. "
"Generated:\n{}\n".format("\n".join(actual)))
finally:
parser.ignore_comments = temp
def normal_fea(self, lines):
output = []