summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2012-02-13 12:11:27 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2012-02-13 12:11:27 (GMT)
commit86f67123befc7f5fe76c97d7e08502846f04722d (patch)
tree568ed36878317b729f0583d5f171619d565a6e7c /Lib/test
parent5211ffe4df8ea41423c1a37635f7c1263a1db754 (diff)
downloadcpython-86f67123befc7f5fe76c97d7e08502846f04722d.zip
cpython-86f67123befc7f5fe76c97d7e08502846f04722d.tar.gz
cpython-86f67123befc7f5fe76c97d7e08502846f04722d.tar.bz2
Fix htmlparser tests to always use the right collector.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_htmlparser.py28
1 files changed, 26 insertions, 2 deletions
diff --git a/Lib/test/test_htmlparser.py b/Lib/test/test_htmlparser.py
index 2e7277e..3d3f859 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', '</')])
+ self._run_check("</a", [('data', '</a')])
+ # XXX this might be wrong
+ self._run_check("<a<a>", [('data', '<a'), ('starttag', 'a', [])])
+ self._run_check("</a<a>", [('endtag', 'a<a')])
+ self._run_check("<!", [('data', '<!')])
+ self._run_check("<a", [('data', '<a')])
+ self._run_check("<a foo='bar'", [('data', "<a foo='bar'")])
+ self._run_check("<a foo='bar", [('data', "<a foo='bar")])
+ self._run_check("<a foo='>'", [('data', "<a foo='>'")])
+ self._run_check("<a foo='>", [('data', "<a foo='>")])
+
+ def test_declaration_junk_chars(self):
+ # XXX this is wrong
+ self._run_check("<!DOCTYPE foo $ >", [('comment', 'DOCTYPE foo $ ')])
+
+ def test_illegal_declarations(self):
+ # XXX this might be wrong
+ self._run_check('<!spacer type="block" height="25">',
+ [('comment', 'spacer type="block" height="25"')])
+
def test_with_unquoted_attributes(self):
# see #12008
html = ("<html><body bgcolor=d0ca90 text='181008'>"
@@ -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('&#0038;'),'&')
# see #12888