+++ /dev/null
-'''Test module to thest the xmllib module.\r
- Sjoerd Mullender\r
-'''\r
-\r
-testdoc = """\\r
-<?xml version="1.0" encoding="UTF-8" standalone='yes' ?>\r
-<!-- comments aren't allowed before the <?xml?> tag,\r
- but they are allowed before the <!DOCTYPE> tag -->\r
-<?processing instructions are allowed in the same places as comments ?>\r
-<!DOCTYPE greeting [\r
- <!ELEMENT greeting (#PCDATA)>\r
-]>\r
-<greeting>Hello, world!</greeting>\r
-"""\r
-\r
-nsdoc = "<foo xmlns='URI' attr='val'/>"\r
-\r
-from test import test_support\r
-import unittest\r
-# Silence Py3k warning\r
-xmllib = test_support.import_module('xmllib', deprecated=True)\r
-\r
-class XMLParserTestCase(unittest.TestCase):\r
-\r
- def test_simple(self):\r
- parser = xmllib.XMLParser()\r
- for c in testdoc:\r
- parser.feed(c)\r
- parser.close()\r
-\r
- def test_default_namespace(self):\r
- class H(xmllib.XMLParser):\r
- def unknown_starttag(self, name, attr):\r
- self.name, self.attr = name, attr\r
- h=H()\r
- h.feed(nsdoc)\r
- h.close()\r
- # The default namespace applies to elements...\r
- self.assertEqual(h.name, "URI foo")\r
- # but not to attributes\r
- self.assertEqual(h.attr, {'attr':'val'})\r
-\r
-\r
-def test_main():\r
- test_support.run_unittest(XMLParserTestCase)\r
-\r
-if __name__ == "__main__":\r
- test_main()\r