diff Lib/test/test_htmlparser.py @ 75117:2d16048b10cd 3.2

HTMLParser is now able to handle slashes in the start tag.
author Ezio Melotti <ezio.melotti@gmail.com>
date Tue, 21 Feb 2012 09:25:00 +0200
parents 586d688dcf7f
children ba4baaddac8d
line wrap: on
line diff
--- a/Lib/test/test_htmlparser.py	Tue Feb 21 00:32:36 2012 +0100
+++ b/Lib/test/test_htmlparser.py	Tue Feb 21 09:25:00 2012 +0200
@@ -389,6 +389,27 @@
         self._run_check("<a foo='>'", [('data', "<a foo='>'")])
         self._run_check("<a foo='>", [('data', "<a foo='>")])
 
+    def test_slashes_in_starttag(self):
+        self._run_check('<a foo="var"/>', [('startendtag', 'a', [('foo', 'var')])])
+        html = ('<img width=902 height=250px '
+                'src="/sites/default/files/images/homepage/foo.jpg" '
+                '/*what am I doing here*/ />')
+        expected = [(
+            'startendtag', 'img',
+            [('width', '902'), ('height', '250px'),
+             ('src', '/sites/default/files/images/homepage/foo.jpg'),
+             ('*what', None), ('am', None), ('i', None),
+             ('doing', None), ('here*', None)]
+        )]
+        self._run_check(html, expected)
+        html = ('<a / /foo/ / /=/ / /bar/ / />'
+                '<a / /foo/ / /=/ / /bar/ / >')
+        expected = [
+            ('startendtag', 'a', [('foo', None), ('=', None), ('bar', None)]),
+            ('starttag', 'a', [('foo', None), ('=', None), ('bar', None)])
+        ]
+        self._run_check(html, expected)
+
     def test_declaration_junk_chars(self):
         self._run_check("<!DOCTYPE foo $ >", [('decl', 'DOCTYPE foo $ ')])