Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 292f9a8

Browse files
committed
make TestAccelerator[Not]Imported for ElementTree more robust
1 parent 66e6f8e commit 292f9a8

2 files changed

Lines changed: 3 additions & 9 deletions

File tree

Lib/test/test_xml_etree.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1907,9 +1907,7 @@ def __exit__(self, *args):
19071907
class TestAcceleratorNotImported(unittest.TestCase):
19081908
# Test that the C accelerator was not imported for pyET
19091909
def test_correct_import_pyET(self):
1910-
# In the C accelerator, Element is just a factory function, not an
1911-
# actual class. In the Python version it's a class.
1912-
self.assertIsInstance(pyET.Element, type)
1910+
self.assertEqual(pyET.Element.__module__, 'xml.etree.ElementTree')
19131911

19141912

19151913
def test_main(module=pyET):

Lib/test/test_xml_etree_c.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,11 @@ def test_length_overflow(self, size):
4646
finally:
4747
data = None
4848

49+
@unittest.skipUnless(cET, 'requires _elementtree')
4950
class TestAcceleratorImported(unittest.TestCase):
5051
# Test that the C accelerator was imported, as expected
5152
def test_correct_import_cET(self):
52-
# In the C accelerator, Element is just a factory function, not an
53-
# actual class. In the Python version it's a class.
54-
self.assertNotIsInstance(cET.Element, type)
55-
56-
#def test_correct_import_cET_alias(self):
57-
#self.assertNotIsInstance(cET_alias.Element, type)
53+
self.assertEqual(cET.Element.__module__, '_elementtree')
5854

5955

6056
def test_main():

0 commit comments

Comments
 (0)