@@ -37,6 +37,8 @@ def processEmptyTag(self, token):
37
37
self .outputTokens .append ([u"StartTag" , token ["name" ], token ["data" ]])
38
38
39
39
def processEndTag (self , token ):
40
+ if token ["data" ]:
41
+ self .processParseError (None )
40
42
self .outputTokens .append ([u"EndTag" , token ["name" ]])
41
43
42
44
def processComment (self , token ):
@@ -53,7 +55,7 @@ def processEOF(self, token):
53
55
pass
54
56
55
57
def processParseError (self , token ):
56
- self .outputTokens .append ([ u"ParseError" , token [ "data" ]] )
58
+ self .outputTokens .append (u"ParseError" )
57
59
58
60
def concatenateCharacterTokens (tokens ):
59
61
outputTokens = []
@@ -71,10 +73,9 @@ def concatenateCharacterTokens(tokens):
71
73
def normalizeTokens (tokens ):
72
74
""" convert array of attributes to a dictionary """
73
75
# TODO: convert tests to reflect arrays
74
- for i , token in enumerate (tokens ):
75
- if token [0 ] == u'ParseError' :
76
- tokens [i ] = token [0 ]
77
- #token[2] = dict(token[2][::-1])
76
+ for token in tokens :
77
+ if token [0 ] == 'StartTag' :
78
+ token [2 ] = dict (token [2 ][::- 1 ])
78
79
return tokens
79
80
80
81
def tokensMatch (expectedTokens , recievedTokens ):
@@ -101,14 +102,14 @@ def runTokenizerTest(self, test):
101
102
test ['lastStartTag' ] = None
102
103
parser = TokenizerTestParser (test ['contentModelFlag' ],
103
104
test ['lastStartTag' ])
104
- tokens = parser .parse (test ['input' ])
105
+
106
+ tokens = normalizeTokens (parser .parse (test ['input' ]))
105
107
tokens = concatenateCharacterTokens (tokens )
106
108
errorMsg = "\n " .join (["\n \n Content Model Flag:" ,
107
109
test ['contentModelFlag' ] ,
108
110
"\n Input:" , str (test ['input' ]),
109
111
"\n Expected:" , str (output ),
110
112
"\n Recieved:" , str (tokens )])
111
- tokens = normalizeTokens (tokens )
112
113
self .assertEquals (tokensMatch (tokens , output ), True , errorMsg )
113
114
114
115
def buildTestSuite ():
0 commit comments