in the tests of ElementTree, verify that the C accelerator is imported or not imported as expected

This commit is contained in:
Eli Bendersky 2012-02-16 06:52:39 +02:00
parent 4aec77617f
commit da57819efa
2 changed files with 21 additions and 1 deletions

View file

@ -1904,12 +1904,22 @@ class CleanContext(object):
self.checkwarnings.__exit__(*args)
class TestAcceleratorNotImported(unittest.TestCase):
# Test that the C accelerator was not imported for pyET
def test_correct_import_pyET(self):
# In the C accelerator, Element is just a factory function, not an
# actual class. In the Python version it's a class.
self.assertIsInstance(pyET.Element, type)
def test_main(module=pyET):
from test import test_xml_etree
# The same doctests are used for both the Python and the C implementations
test_xml_etree.ET = module
support.run_unittest(TestAcceleratorNotImported)
# XXX the C module should give the same warnings as the Python module
with CleanContext(quiet=(module is not pyET)):
support.run_doctest(test_xml_etree, verbosity=True)