Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +0000 | [diff] [blame] | 1 | # xml.etree test for cElementTree |
Fredrik Lundh | 9235ea4 | 2005-12-15 18:41:22 +0000 | [diff] [blame] | 2 | |
Benjamin Peterson | ee8712c | 2008-05-20 21:35:26 +0000 | [diff] [blame] | 3 | from test import support |
Fredrik Lundh | 9235ea4 | 2005-12-15 18:41:22 +0000 | [diff] [blame] | 4 | |
Florent Xicluna | f15351d | 2010-03-13 23:24:31 +0000 | [diff] [blame] | 5 | cET = support.import_module('xml.etree.cElementTree') |
Fredrik Lundh | 8911ca3d | 2005-12-16 22:07:17 +0000 | [diff] [blame] | 6 | |
Fredrik Lundh | 9235ea4 | 2005-12-15 18:41:22 +0000 | [diff] [blame] | 7 | |
Florent Xicluna | f15351d | 2010-03-13 23:24:31 +0000 | [diff] [blame] | 8 | # cElementTree specific tests |
Fredrik Lundh | 9235ea4 | 2005-12-15 18:41:22 +0000 | [diff] [blame] | 9 | |
| 10 | def sanity(): |
| 11 | """ |
| 12 | Import sanity. |
| 13 | |
Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +0000 | [diff] [blame] | 14 | >>> from xml.etree import cElementTree |
Fredrik Lundh | 9235ea4 | 2005-12-15 18:41:22 +0000 | [diff] [blame] | 15 | """ |
| 16 | |
Thomas Wouters | 00ee7ba | 2006-08-21 19:07:27 +0000 | [diff] [blame] | 17 | |
Fredrik Lundh | 9235ea4 | 2005-12-15 18:41:22 +0000 | [diff] [blame] | 18 | def test_main(): |
Florent Xicluna | f15351d | 2010-03-13 23:24:31 +0000 | [diff] [blame] | 19 | from test import test_xml_etree, test_xml_etree_c |
| 20 | |
| 21 | # Run the tests specific to the C implementation |
Benjamin Peterson | ee8712c | 2008-05-20 21:35:26 +0000 | [diff] [blame] | 22 | support.run_doctest(test_xml_etree_c, verbosity=True) |
Fredrik Lundh | 9235ea4 | 2005-12-15 18:41:22 +0000 | [diff] [blame] | 23 | |
Florent Xicluna | f15351d | 2010-03-13 23:24:31 +0000 | [diff] [blame] | 24 | # 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 Lundh | 9235ea4 | 2005-12-15 18:41:22 +0000 | [diff] [blame] | 38 | if __name__ == '__main__': |
| 39 | test_main() |