#23144: Make sure that HTMLParser.feed() returns all the data, even when convert_charrefs is True.

This commit is contained in:
Ezio Melotti 2015-09-06 21:38:06 +03:00
parent 527ef0792f
commit 6f2bb98966
3 changed files with 25 additions and 5 deletions

View file

@ -72,9 +72,6 @@ class EventCollectorExtra(EventCollector):
class EventCollectorCharrefs(EventCollector):
def get_events(self):
return self.events
def handle_charref(self, data):
self.fail('This should never be called with convert_charrefs=True')
@ -685,6 +682,18 @@ class HTMLParserTolerantTestCase(HTMLParserStrictTestCase):
]
self._run_check(html, expected)
def test_convert_charrefs_dropped_text(self):
# #23144: make sure that all the events are triggered when
# convert_charrefs is True, even if we don't call .close()
parser = EventCollector(convert_charrefs=True)
# before the fix, bar & baz was missing
parser.feed("foo <a>link</a> bar &amp; baz")
self.assertEqual(
parser.get_events(),
[('data', 'foo '), ('starttag', 'a', []), ('data', 'link'),
('endtag', 'a'), ('data', ' bar & baz')]
)
class AttributesStrictTestCase(TestCaseBase):