diff Lib/test/test_htmlparser.py @ 73159:41d41776aa6d 3.2

#13273: fix a bug that prevented HTMLParser to properly detect some tags when strict=False.
author Ezio Melotti <ezio.melotti@gmail.com>
date Fri, 28 Oct 2011 13:21:09 +0300
parents 9896fc2a8167
children a6f2244b251f
line wrap: on
line diff
--- a/Lib/test/test_htmlparser.py	Fri Oct 28 12:32:53 2011 +0300
+++ b/Lib/test/test_htmlparser.py	Fri Oct 28 13:21:09 2011 +0300
@@ -373,6 +373,39 @@
                                 [('action', 'bogus|&#()value')])],
                         collector = self.collector)
 
+    def test_issue13273(self):
+        html = ('<div style=""    ><b>The <a href="some_url">rain</a> '
+                '<br /> in <span>Spain</span></b></div>')
+        expected = [
+            ('starttag', 'div', [('style', '')]),
+            ('starttag', 'b', []),
+            ('data', 'The '),
+            ('starttag', 'a', [('href', 'some_url')]),
+            ('data', 'rain'),
+            ('endtag', 'a'),
+            ('data', ' '),
+            ('startendtag', 'br', []),
+            ('data', ' in '),
+            ('starttag', 'span', []),
+            ('data', 'Spain'),
+            ('endtag', 'span'),
+            ('endtag', 'b'),
+            ('endtag', 'div')
+        ]
+        self._run_check(html, expected, collector=self.collector)
+
+    def test_issue13273_2(self):
+        html = '<div style="", foo = "bar" ><b>The <a href="some_url">rain</a>'
+        expected = [
+            ('starttag', 'div', [('style', ''), ('foo', 'bar')]),
+            ('starttag', 'b', []),
+            ('data', 'The '),
+            ('starttag', 'a', [('href', 'some_url')]),
+            ('data', 'rain'),
+            ('endtag', 'a'),
+        ]
+        self._run_check(html, expected, collector=self.collector)
+
     def test_unescape_function(self):
         p = html.parser.HTMLParser()
         self.assertEqual(p.unescape('&#bad;'),'&#bad;')