]> git.proxmox.com Git - mirror_edk2.git/blob - AppPkg/Applications/Python/Python-2.7.2/Lib/test/test_xml_etree_c.py
EmbeddedPkg: Extend NvVarStoreFormattedLib LIBRARY_CLASS
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.2 / Lib / test / test_xml_etree_c.py
1 # xml.etree test for cElementTree
2
3 from test import test_support
4 from test.test_support import precisionbigmemtest, _2G
5 import unittest
6
7 cET = test_support.import_module('xml.etree.cElementTree')
8
9
10 # cElementTree specific tests
11
12 def sanity():
13 """
14 Import sanity.
15
16 >>> from xml.etree import cElementTree
17 """
18
19
20 class MiscTests(unittest.TestCase):
21 # Issue #8651.
22 @precisionbigmemtest(size=_2G + 100, memuse=1)
23 def test_length_overflow(self, size):
24 if size < _2G + 100:
25 self.skipTest("not enough free memory, need at least 2 GB")
26 data = b'x' * size
27 parser = cET.XMLParser()
28 try:
29 self.assertRaises(OverflowError, parser.feed, data)
30 finally:
31 data = None
32
33
34 def test_main():
35 from test import test_xml_etree, test_xml_etree_c
36
37 # Run the tests specific to the C implementation
38 test_support.run_doctest(test_xml_etree_c, verbosity=True)
39
40 # Assign the C implementation before running the doctests
41 # Patch the __name__, to prevent confusion with the pure Python test
42 pyET = test_xml_etree.ET
43 py__name__ = test_xml_etree.__name__
44 test_xml_etree.ET = cET
45 if __name__ != '__main__':
46 test_xml_etree.__name__ = __name__
47 try:
48 # Run the same test suite as xml.etree.ElementTree
49 test_xml_etree.test_main(module_name='xml.etree.cElementTree')
50 finally:
51 test_xml_etree.ET = pyET
52 test_xml_etree.__name__ = py__name__
53
54 if __name__ == '__main__':
55 test_main()