8000 Make it possible to ignore parse errors · html5lib/html5lib-python@21e06bb · GitHub
[go: up one dir, main page]

Skip to content

Commit 21e06bb

Browse files
author
James Graham
committed
Make it possible to ignore parse errors
1 parent 4d53508 commit 21e06bb

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

html5lib/tests/test_tokenizer.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ def normalizeTokens(tokens):
8888
tokens[i] = token[0]
8989
return tokens
9090

91-
def tokensMatch(expectedTokens, receivedTokens, ignoreErrorOrder):
91+
def tokensMatch(expectedTokens, receivedTokens, ignoreErrorOrder,
92+
ignoreErrors=True):
9293
"""Test whether the test has passed or failed
9394
9495
If the ignoreErrorOrder flag is set to true we don't test the relative
@@ -117,8 +118,8 @@ def tokensMatch(expectedTokens, receivedTokens, ignoreErrorOrder):
117118
if token != "ParseError":
118119
tokens[tokenType][0].append(token)
119120
else:
120-
tokens[tokenType][1].append(token)
121-
121+
if not ignoreErrors:
122+
tokens[tokenType][1].append(token)
122123
return tokens["expected"] == tokens["received"]
123124

124125
def unescape_test(test):
@@ -135,7 +136,6 @@ def decode(inp):
135136
for key, value in token[2]:
136137
del token[2][key]
137138
token[2][decode(key)] = decode(value)
138-
sys.stderr.write(str(test))
139139
return test
140140

141141
class TestCase(unittest.TestCase):
@@ -180,7 +180,6 @@ def capitalize(s):
180180

181181
def buildTestSuite():
182182
for filename in html5lib_test_files('tokenizer', '*.test'):
183-
print filename
184183
tests = json.load(file(filename))
185184
testName = os.path.basename(filename).replace(".test","")
186185
if 'tests' in tests:

0 commit comments

Comments
 (0)
0