[ZPT] CVS: Packages/TAL - test_htmlparser.py:1.6
guido@digicool.com
guido@digicool.com
Sat, 24 Mar 2001 14:32:56 -0500 (EST)
Update of /cvs-repository/Packages/TAL/test
In directory korak:/tmp/cvs-serv17792
Modified Files:
test_htmlparser.py
Log Message:
Add tests for improperly closed start and end tag (< instead of >).
Add test for get_starttag_text().
--- Updated File test_htmlparser.py in package Packages/TAL --
--- test_htmlparser.py 2001/03/22 17:54:13 1.5
+++ test_htmlparser.py 2001/03/24 19:32:55 1.6
@@ -60,10 +60,16 @@
self.append(("pi", data))
+class EventCollectorExtra(EventCollector):
+
+ def handle_starttag(self, tag, attrs):
+ EventCollector.handle_starttag(self, tag, attrs)
+ self.append(("starttag_text", self.get_starttag_text()))
+
class HTMLParserTestCase(unittest.TestCase):
- def _run_check(self, source, events):
- parser = EventCollector()
+ def _run_check(self, source, events, collector=EventCollector):
+ parser = collector()
if isinstance(source, type([])):
for s in source:
parser.feed(s)
@@ -72,6 +78,9 @@
parser.close()
self.assert_(parser.get_events() == events, parser.get_events())
+ def _run_check_extra(self, source, events):
+ self._run_check(source, events, EventCollectorExtra)
+
def _parse_error(self, source):
def parse(source=source):
parser = HTMLParser.HTMLParser()
@@ -171,7 +180,8 @@
self._parse_error("</")
self._parse_error("</a")
self._parse_error("</a")
-## self._parse_error("</a<a>")
+ self._parse_error("<a<a>")
+ self._parse_error("</a<a>")
self._parse_error("<$")
self._parse_error("<$>")
self._parse_error("<!")
@@ -198,6 +208,12 @@
("startendtag", "img", [("src", "foo")]),
("endtag", "p"),
])
+
+ def check_get_starttag_text(self):
+ s = """<foo:bar \n one="1"\ttwo=2 >"""
+ self._run_check_extra(s, [
+ ("starttag", "foo:bar", [("one", "1"), ("two", "2")]),
+ ("starttag_text", s)])
# Support for the Zope regression test framework: