Skip to content

Commit 2660421

Browse files
committed
simplify test_parser() in test_parser.py; now the new lines are no longer needed
--HG-- extra : convert_revision : svn%3Aacbfec75-9323-0410-a652-858a13e371e0/trunk%40329
1 parent 7588d9d commit 2660421

1 file changed

Lines changed: 7 additions & 16 deletions

File tree

tests/test_parser.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,22 +59,13 @@ def runParserTest(self, input, output, errors):
5959
def test_parser():
6060
for filename in glob.glob('tree-construction/*.dat'):
6161
f = open(filename)
62-
test = []
63-
documentSeen = False
64-
for line in f:
65-
# XXX This algorithm would need to be changed if we want to get rid
66-
# of the double newline requirement at the end of test files.
67-
if line.startswith("#document"):
68-
documentSeen = True
69-
if not line == "\n":
70-
test.append(line[:-1])
71-
elif line == "\n" and not documentSeen:
72-
test.append(line[:-1])
73-
else:
74-
input, output, errors = parseTestcase("\n".join(test))
75-
yield TestCase.runParserTest, input, output, errors
76-
test = []
77-
documentSeen = False
62+
tests = f.read().split("#data\n")
63+
for test in tests:
64+
if test == "":
65+
continue
66+
test = "#data\n" + test
67+
input, output, errors = parseTestcase(test)
68+
yield TestCase.runParserTest, input, output, errors
7869

7970
def buildTestSuite():
8071
tests = 0

0 commit comments

Comments
 (0)