LEFT | RIGHT |
1 # xml.etree test for cElementTree | 1 # xml.etree test for cElementTree |
2 | 2 |
3 from test import test_support | 3 from test import test_support |
4 | 4 |
5 cET = test_support.import_module('xml.etree.cElementTree') | 5 cET = test_support.import_module('xml.etree.cElementTree') |
6 | 6 |
7 | 7 |
8 # -------------------------------------------------------------------- | |
9 # cElementTree specific tests | 8 # cElementTree specific tests |
10 | 9 |
11 def sanity(): | 10 def sanity(): |
12 """ | 11 """ |
13 Import sanity. | 12 Import sanity. |
14 | 13 |
15 >>> from xml.etree import cElementTree | 14 >>> from xml.etree import cElementTree |
16 """ | 15 """ |
17 | 16 |
18 # -------------------------------------------------------------------- | |
19 | 17 |
20 def test_main(): | 18 def test_main(): |
21 from test import test_xml_etree, test_xml_etree_c | 19 from test import test_xml_etree, test_xml_etree_c |
22 | 20 |
23 # Run the tests specific to the C implementation | 21 # Run the tests specific to the C implementation |
24 test_support.run_doctest(test_xml_etree_c, verbosity=True) | 22 test_support.run_doctest(test_xml_etree_c, verbosity=True) |
25 | 23 |
26 # Assign the C implementation before running the doctests | 24 # Assign the C implementation before running the doctests |
27 pyET = test_xml_etree.ET | 25 pyET = test_xml_etree.ET |
28 test_xml_etree.ET = cET | 26 test_xml_etree.ET = cET |
29 try: | 27 try: |
30 # Run the same test suite as xml.etree.ElementTree | 28 # Run the same test suite as xml.etree.ElementTree |
31 test_xml_etree.test_main(module_name='xml.etree.cElementTree') | 29 test_xml_etree.test_main(module_name='xml.etree.cElementTree') |
32 finally: | 30 finally: |
33 test_xml_etree.ET = pyET | 31 test_xml_etree.ET = pyET |
34 | 32 |
35 if __name__ == '__main__': | 33 if __name__ == '__main__': |
36 test_main() | 34 test_main() |
LEFT | RIGHT |