blob: ee270f900dd9d311b822b27097e4af67668053d1 [file] [log] [blame]
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001# xml.etree test for cElementTree
Fredrik Lundh9235ea42005-12-15 18:41:22 +00002
Benjamin Petersonee8712c2008-05-20 21:35:26 +00003from test import support
Fredrik Lundh9235ea42005-12-15 18:41:22 +00004
Florent Xiclunaf15351d2010-03-13 23:24:31 +00005cET = support.import_module('xml.etree.cElementTree')
Fredrik Lundh8911ca3d2005-12-16 22:07:17 +00006
Fredrik Lundh9235ea42005-12-15 18:41:22 +00007
Florent Xiclunaf15351d2010-03-13 23:24:31 +00008# cElementTree specific tests
Fredrik Lundh9235ea42005-12-15 18:41:22 +00009
10def sanity():
11 """
12 Import sanity.
13
Thomas Wouters0e3f5912006-08-11 14:57:12 +000014 >>> from xml.etree import cElementTree
Fredrik Lundh9235ea42005-12-15 18:41:22 +000015 """
16
Thomas Wouters00ee7ba2006-08-21 19:07:27 +000017
Fredrik Lundh9235ea42005-12-15 18:41:22 +000018def test_main():
Florent Xiclunaf15351d2010-03-13 23:24:31 +000019 from test import test_xml_etree, test_xml_etree_c
20
21 # Run the tests specific to the C implementation
Benjamin Petersonee8712c2008-05-20 21:35:26 +000022 support.run_doctest(test_xml_etree_c, verbosity=True)
Fredrik Lundh9235ea42005-12-15 18:41:22 +000023
Florent Xiclunaf15351d2010-03-13 23:24:31 +000024 # Assign the C implementation before running the doctests
25 # Patch the __name__, to prevent confusion with the pure Python test
26 pyET = test_xml_etree.ET
27 py__name__ = test_xml_etree.__name__
28 test_xml_etree.ET = cET
29 if __name__ != '__main__':
30 test_xml_etree.__name__ = __name__
31 try:
32 # Run the same test suite as xml.etree.ElementTree
33 test_xml_etree.test_main(module_name='xml.etree.cElementTree')
34 finally:
35 test_xml_etree.ET = pyET
36 test_xml_etree.__name__ = py__name__
37
Fredrik Lundh9235ea42005-12-15 18:41:22 +000038if __name__ == '__main__':
39 test_main()