mirror of
https://github.com/python/cpython.git
synced 2025-10-06 15:11:58 +00:00
#17802: Fix an UnboundLocalError in html.parser. Initial tests by Thomas Barlow.
This commit is contained in:
parent
a771a1b48e
commit
8e596a765c
3 changed files with 18 additions and 0 deletions
|
@ -535,6 +535,20 @@ class HTMLParserTolerantTestCase(HTMLParserStrictTestCase):
|
|||
]
|
||||
self._run_check(html, expected)
|
||||
|
||||
def test_EOF_in_charref(self):
|
||||
# see #17802
|
||||
# This test checks that the UnboundLocalError reported in the issue
|
||||
# is not raised, however I'm not sure the returned values are correct.
|
||||
# Maybe HTMLParser should use self.unescape for these
|
||||
data = [
|
||||
('a&', [('data', 'a&')]),
|
||||
('a&b', [('data', 'ab')]),
|
||||
('a&b ', [('data', 'a'), ('entityref', 'b'), ('data', ' ')]),
|
||||
('a&b;', [('data', 'a'), ('entityref', 'b')]),
|
||||
]
|
||||
for html, expected in data:
|
||||
self._run_check(html, expected)
|
||||
|
||||
def test_unescape_function(self):
|
||||
p = self.get_collector()
|
||||
self.assertEqual(p.unescape('&#bad;'),'&#bad;')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue