make TestAccelerator[Not]Imported for ElementTree more robust
authorEli Bendersky <eliben@gmail.com>
Thu, 16 Feb 2012 17:55:29 +0000 (19:55 +0200)
committerEli Bendersky <eliben@gmail.com>
Thu, 16 Feb 2012 17:55:29 +0000 (19:55 +0200)
Lib/test/test_xml_etree.py
Lib/test/test_xml_etree_c.py

index 0d1eb2241c09529348dc317516c680a3c81529b5..6060e06732d78e94009014ab7c368624718d1d0c 100644 (file)
@@ -1907,9 +1907,7 @@ class CleanContext(object):
 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)
+        self.assertEqual(pyET.Element.__module__, 'xml.etree.ElementTree')
 
 
 def test_main(module=pyET):
index d821b81b7affd9d9fa2d6d27e4233800fac521e9..dbe1c3aff147d3b948db8fe38b8c38051c8b5b70 100644 (file)
@@ -46,15 +46,11 @@ class MiscTests(unittest.TestCase):
         finally:
             data = None
 
+@unittest.skipUnless(cET, 'requires _elementtree')
 class TestAcceleratorImported(unittest.TestCase):
     # Test that the C accelerator was imported, as expected
     def test_correct_import_cET(self):
-        # In the C accelerator, Element is just a factory function, not an
-        # actual class. In the Python version it's a class.
-        self.assertNotIsInstance(cET.Element, type)
-
-    #def test_correct_import_cET_alias(self):
-        #self.assertNotIsInstance(cET_alias.Element, type)
+        self.assertEqual(cET.Element.__module__, '_elementtree')
 
 
 def test_main():