From 458120dd40db6b4df55a4e96b650e16798ef06a0 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Tue, 3 May 2011 11:25:13 +0000 Subject: add hg and python --- sys/lib/python/test/test_htmllib.py | 69 +++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 sys/lib/python/test/test_htmllib.py (limited to 'sys/lib/python/test/test_htmllib.py') diff --git a/sys/lib/python/test/test_htmllib.py b/sys/lib/python/test/test_htmllib.py new file mode 100644 index 000000000..a20f43bbf --- /dev/null +++ b/sys/lib/python/test/test_htmllib.py @@ -0,0 +1,69 @@ +import formatter +import htmllib +import unittest + +from test import test_support + + +class AnchorCollector(htmllib.HTMLParser): + def __init__(self, *args, **kw): + self.__anchors = [] + htmllib.HTMLParser.__init__(self, *args, **kw) + + def get_anchor_info(self): + return self.__anchors + + def anchor_bgn(self, *args): + self.__anchors.append(args) + +class DeclCollector(htmllib.HTMLParser): + def __init__(self, *args, **kw): + self.__decls = [] + htmllib.HTMLParser.__init__(self, *args, **kw) + + def get_decl_info(self): + return self.__decls + + def unknown_decl(self, data): + self.__decls.append(data) + + +class HTMLParserTestCase(unittest.TestCase): + def test_anchor_collection(self): + # See SF bug #467059. + parser = AnchorCollector(formatter.NullFormatter(), verbose=1) + parser.feed( + """ + + + """) + parser.close() + self.assertEquals(parser.get_anchor_info(), + [('http://foo.org/', 'splat', ''), + ('http://www.python.org/', '', ''), + ('', 'frob', ''), + ]) + + def test_decl_collection(self): + # See SF patch #545300 + parser = DeclCollector(formatter.NullFormatter(), verbose=1) + parser.feed( + """ + + hallo +   + + + """) + parser.close() + self.assertEquals(parser.get_decl_info(), + ["if !supportEmptyParas", + "endif" + ]) + +def test_main(): + test_support.run_unittest(HTMLParserTestCase) + + +if __name__ == "__main__": + test_main() -- cgit v1.2.3