8000 Fixed test_sax wrt parser's passing qname to startElementNS and endEl… · html5lib/html5lib-python@feb3f51 · GitHub
[go: up one dir, main page]

Skip to content

Commit feb3f51

Browse files
committed
Fixed test_sax wrt parser's passing qname to startElementNS and endElementNS and handling of whitespace.
--HG-- extra : convert_revision : svn%3Aacbfec75-9323-0410-a652-858a13e371e0/trunk%40771
1 parent e822736 commit feb3f51

File tree

1 file changed

+34
-28
lines changed

1 file changed

+34
-28
lines changed

tests/test_sax.py

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,14 @@ def setDocumentLocator(self, locator):
2828
pass
2929
def startElement(self, name, attrs):
3030
self.log.append(['startElement', name, dict(attrs.items())])
31-
def startElementNS(self, name, qname, attrs):
32-
self.log.append(['startElementNS', name, qname, dict(attrs.items())])
31+
def startElementNS(self, name, qname, attrs):
32+
if qname is None:
33+
qname = name[1]
34+
self.log.append(['startElementNS', name, qname, dict(attrs.items())])
35+
def endElementNS(self, name, qname):
36+
if qname is None:
37+
qname = name[1]
38+
self.log.append(['endElementNS', name, qname])
3339
def __getattr__(self, name):
3440
def function(self, *args): self.log.append([name]+list(args))
3541
return new.instancemethod(function, self, SAXLogger)
@@ -59,8 +65,8 @@ def saxdiff(self, input):
5965
for i in range(0,len(saxhandler.log)):
6066
if i > len(domhandler.log):
6167
self.assertEqual(saxhandler.log[i:], domhandler.log[i:])
62-
elif saxhandler.log[i] != domhandler.log[i]:
63-
self.assertEqual(saxhandler.log[i], domhandler.log[i])
68+
elif saxhandler.log[i] != domhandler.log[i]:
69+
self.assertEqual(saxhandler.log[i], domhandler.log[i])
6470
else:
6571
self.assertEquals(saxhandler.log, domhandler.log)
6672

@@ -74,30 +80,30 @@ def test_xmllang(self):
7480

7581
def test_ns(self):
7682
self.saxdiff(
77-
"""<html xmlns="http://www.w3.org/1999/xhtml">
78-
<head><title>XLINK</title></head>
79-
<body>
80-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
81-
<defs xmlns:l="http://www.w3.org/1999/xlink">
82-
<radialGradient id="s1" fx=".4" fy=".2" r=".7">
83-
<stop stop-color="#FE8"/>
84-
<stop stop-color="#D70" offset="1"/>
85-
</radialGradient>
86-
<radialGradient id="s2" fx=".8" fy=".5" l:href="#s1"/>
87-
<radialGradient id="s3" fx=".5" fy=".9" l:href="#s1"/>
88-
<radialGradient id="s4" fx=".1" fy=".5" l:href="#s1"/>
89-
</defs>
90-
<g stroke="#940">
91-
<path d="M73,29c-37-40-62-24-52,4l6-7c-8-16,7-26,42,9z" fill="url(#s1)"/>
92-
<path d="M47,8c33-16,48,21,9,47l-6-5c38-27,20-44,5-37z" fill="url(#s2)"/>
93-
<path d="M77,32c22,30,10,57-39,51l-1-8c3,3,67,5,36-36z" fill="url(#s3)"/>
94-
95-
<path d="M58,84c-4,20-38-4-8-24l-6-5c-36,43,15,56,23,27z" fill="url(#s4)"/>
96-
<path d="M40,14c-40,37-37,52-9,68l1-8c-16-13-29-21,16-56z" fill="url(#s1)"/>
97-
<path d="M31,33c19,23,20,7,35,41l-9,1.7c-4-19-8-14-31-37z" fill="url(#s2)"/>
98-
</g>
99-
</svg>
100-
</body></html>""")
83+
'<html xmlns="http://www.w3.org/1999/xhtml">' +
84+
'<head><title>XLINK</title></head>' +
85+
'<body>' +
86+
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">' +
87+
'<defs xmlns:l="http://www.w3.org/1999/xlink">' +
88+
'<radialGradient id="s1" fx=".4" fy=".2" r=".7">' +
89+
'<stop stop-color="#FE8"/>' +
90+
'<stop stop-color="#D70" offset="1"/>' +
91+
'</radialGradient>' +
92+
'<radialGradient id="s2" fx=".8" fy=".5" l:href="#s1"/>' +
93+
'<radialGradient id="s3" fx=".5" fy=".9" l:href="#s1"/>' +
94+
'<radialGradient id="s4" fx=".1" fy=".5" l:href="#s1"/>' +
95+
'</defs>' +
96+
'<g stroke="#940">' +
97+
'<path d="M73,29c-37-40-62-24-52,4l6-7c-8-16,7-26,42,9z" fill="url(#s1)"/>' +
98+
'<path d="M47,8c33-16,48,21,9,47l-6-5c38-27,20-44,5-37z" fill="url(#s2)"/>' +
99+
'<path d="M77,32c22,30,10,57-39,51l-1-8c3,3,67,5,36-36z" fill="url(#s3)"/>' +
100+
101+
'<path d="M58,84c-4,20-38-4-8-24l-6-5c-36,43,15,56,23,27z" fill="url(#s4)"/>' +
102+
'<path d="M40,14c-40,37-37,52-9,68l1-8c-16-13-29-21,16-56z" fill="url(#s1)"/>' +
103+
'<path d="M31,33c19,23,20,7,35,41l-9,1.7c-4-19-8-14-31-37z" fill="url(#s2)"/>' +
104+
'</g>' +
105+
'</svg>' +
106+
'</body></html>')
101107

102108
# Repeat tests without namespace support
103109
class nonamespaceTest(SAXTest):

0 commit comments

Comments
 (0)
0