Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit542dc08

Browse files
author
James Graham
committed
Move tests that are problematic in json or java to a single file. Add double escaping flag to sneak unpaired surrogates past over-zealous json decoders
1 parent51460c0 commit542dc08

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

‎html5lib/tests/test_tokenizer.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def normalizeTokens(tokens):
8686
fori,tokeninenumerate(tokens):
8787
iftoken[0]==u'ParseError':
8888
tokens[i]=token[0]
89-
returnjson.loads(json.dumps(tokens))
89+
returntokens
9090

9191
deftokensMatch(expectedTokens,receivedTokens,ignoreErrorOrder):
9292
"""Test whether the test has passed or failed
@@ -121,12 +121,31 @@ def tokensMatch(expectedTokens, receivedTokens, ignoreErrorOrder):
121121

122122
returntokens["expected"]==tokens["received"]
123123

124+
defunescape_test(test):
125+
defdecode(inp):
126+
returninp.decode("unicode-escape")
127+
128+
test["input"]=decode(test["input"])
129+
fortokenintest["output"]:
130+
iftoken=="ParseError":
131+
continue
132+
else:
133+
token[1]=decode(token[1])
134+
iflen(token)>2:
135+
forkey,valueintoken[2]:
136+
deltoken[2][key]
137+
token[2][decode(key)]=decode(value)
138+
sys.stderr.write(str(test))
139+
returntest
124140

125141
classTestCase(unittest.TestCase):
126142
defrunTokenizerTest(self,test):
127143
#XXX - move this out into the setup function
128144
#concatenate all consecutive character tokens into a single token
129-
expected=concatenateCharacterTokens(test['output'])
145+
if'doubleEscaped'intest:
146+
test=unescape_test(test)
147+
148+
expected=concatenateCharacterTokens(test['output'])
130149
if'lastStartTag'notintest:
131150
test['lastStartTag']=None
132151
outBuffer=cStringIO.StringIO()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp