]> git.proxmox.com Git - mirror_edk2.git/blame - AppPkg/Applications/Python/Python-2.7.2/Lib/test/test_xmllib.py
EmbeddedPkg: Extend NvVarStoreFormattedLib LIBRARY_CLASS
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.2 / Lib / test / test_xmllib.py
CommitLineData
4710c53d 1'''Test module to thest the xmllib module.\r
2 Sjoerd Mullender\r
3'''\r
4\r
5testdoc = """\\r
6<?xml version="1.0" encoding="UTF-8" standalone='yes' ?>\r
7<!-- comments aren't allowed before the <?xml?> tag,\r
8 but they are allowed before the <!DOCTYPE> tag -->\r
9<?processing instructions are allowed in the same places as comments ?>\r
10<!DOCTYPE greeting [\r
11 <!ELEMENT greeting (#PCDATA)>\r
12]>\r
13<greeting>Hello, world!</greeting>\r
14"""\r
15\r
16nsdoc = "<foo xmlns='URI' attr='val'/>"\r
17\r
18from test import test_support\r
19import unittest\r
20# Silence Py3k warning\r
21xmllib = test_support.import_module('xmllib', deprecated=True)\r
22\r
23class XMLParserTestCase(unittest.TestCase):\r
24\r
25 def test_simple(self):\r
26 parser = xmllib.XMLParser()\r
27 for c in testdoc:\r
28 parser.feed(c)\r
29 parser.close()\r
30\r
31 def test_default_namespace(self):\r
32 class H(xmllib.XMLParser):\r
33 def unknown_starttag(self, name, attr):\r
34 self.name, self.attr = name, attr\r
35 h=H()\r
36 h.feed(nsdoc)\r
37 h.close()\r
38 # The default namespace applies to elements...\r
39 self.assertEqual(h.name, "URI foo")\r
40 # but not to attributes\r
41 self.assertEqual(h.attr, {'attr':'val'})\r
42\r
43\r
44def test_main():\r
45 test_support.run_unittest(XMLParserTestCase)\r
46\r
47if __name__ == "__main__":\r
48 test_main()\r