From 86f67123befc7f5fe76c97d7e08502846f04722d Mon Sep 17 00:00:00 2001 From: Ezio Melotti Date: Mon, 13 Feb 2012 14:11:27 +0200 Subject: [PATCH] Fix htmlparser tests to always use the right collector. --- Lib/test/test_htmlparser.py | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_htmlparser.py b/Lib/test/test_htmlparser.py index 2e7277e573d..3d3f8593b55 100644 --- a/Lib/test/test_htmlparser.py +++ b/Lib/test/test_htmlparser.py @@ -93,7 +93,7 @@ class TestCaseBase(unittest.TestCase): def _parse_error(self, source): def parse(source=source): - parser = html.parser.HTMLParser() + parser = self.get_collector() parser.feed(source) parser.close() self.assertRaises(html.parser.HTMLParseError, parse) @@ -368,6 +368,30 @@ class HTMLParserTolerantTestCase(HTMLParserStrictTestCase): ('comment', '/img'), ('endtag', 'html<')]) + def test_starttag_junk_chars(self): + self._run_check("", []) + self._run_check("", [('comment', '$')]) + self._run_check("", [('data', '", [('endtag', 'a'", [('data', "', + [('comment', 'spacer type="block" height="25"')]) + def test_with_unquoted_attributes(self): # see #12008 html = ("" @@ -476,7 +500,7 @@ class HTMLParserTolerantTestCase(HTMLParserStrictTestCase): self._run_check(html, expected) def test_unescape_function(self): - p = html.parser.HTMLParser() + p = self.get_collector() self.assertEqual(p.unescape('&#bad;'),'&#bad;') self.assertEqual(p.unescape('&'),'&') # see #12888