Commit 148fb522 authored by Guido van Rossum's avatar Guido van Rossum

When the argument to _run_check() is a string, feed it to the parser a

character at a time.  This uncovers two new bugs in HTMLParser that
I'm going to attack next.
parent ba3fc790
...@@ -81,12 +81,10 @@ class TestCaseBase(unittest.TestCase): ...@@ -81,12 +81,10 @@ class TestCaseBase(unittest.TestCase):
def _run_check(self, source, events, collector=EventCollector): def _run_check(self, source, events, collector=EventCollector):
parser = collector() parser = collector()
parser.feed(self.prologue) parser.feed(self.prologue)
if isinstance(source, type([])): for s in source:
for s in source: parser.feed(s)
parser.feed(s) for c in self.epilogue:
else: parser.feed(c)
parser.feed(source)
parser.feed(self.epilogue)
parser.close() parser.close()
self.assert_(parser.get_events() == self.assert_(parser.get_events() ==
self.initial_events + events + self.final_events, self.initial_events + events + self.final_events,
...@@ -243,7 +241,6 @@ text ...@@ -243,7 +241,6 @@ text
def check_cdata_content(self): def check_cdata_content(self):
s = """<script> <!-- not a comment --> &not-an-entity-ref; </script>""" s = """<script> <!-- not a comment --> &not-an-entity-ref; </script>"""
s = list(s)
self._run_check(s, [ self._run_check(s, [
("starttag", "script", []), ("starttag", "script", []),
("data", " <!-- not a comment --> &not-an-entity-ref; "), ("data", " <!-- not a comment --> &not-an-entity-ref; "),
......
...@@ -81,12 +81,10 @@ class TestCaseBase(unittest.TestCase): ...@@ -81,12 +81,10 @@ class TestCaseBase(unittest.TestCase):
def _run_check(self, source, events, collector=EventCollector): def _run_check(self, source, events, collector=EventCollector):
parser = collector() parser = collector()
parser.feed(self.prologue) parser.feed(self.prologue)
if isinstance(source, type([])): for s in source:
for s in source: parser.feed(s)
parser.feed(s) for c in self.epilogue:
else: parser.feed(c)
parser.feed(source)
parser.feed(self.epilogue)
parser.close() parser.close()
self.assert_(parser.get_events() == self.assert_(parser.get_events() ==
self.initial_events + events + self.final_events, self.initial_events + events + self.final_events,
...@@ -243,7 +241,6 @@ text ...@@ -243,7 +241,6 @@ text
def check_cdata_content(self): def check_cdata_content(self):
s = """<script> <!-- not a comment --> &not-an-entity-ref; </script>""" s = """<script> <!-- not a comment --> &not-an-entity-ref; </script>"""
s = list(s)
self._run_check(s, [ self._run_check(s, [
("starttag", "script", []), ("starttag", "script", []),
("data", " <!-- not a comment --> &not-an-entity-ref; "), ("data", " <!-- not a comment --> &not-an-entity-ref; "),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment