mirror of
https://github.com/python/cpython.git
synced 2025-11-03 03:22:27 +00:00
Add some testing to verify which module was imported in ET tests.
This is useful when mucking with import_fresh_module to either force or block importing of the _elementtree accelerator. These tests in place provide an immediate indication whether the accelerator was actually imported and overrode the classes it should have.
This commit is contained in:
parent
3a36756ba1
commit
e26fa1bdcb
2 changed files with 15 additions and 2 deletions
|
|
@ -10,6 +10,7 @@ import io
|
|||
import operator
|
||||
import pickle
|
||||
import sys
|
||||
import types
|
||||
import unittest
|
||||
import weakref
|
||||
|
||||
|
|
@ -2398,8 +2399,11 @@ class NoAcceleratorTest(unittest.TestCase):
|
|||
|
||||
# Test that the C accelerator was not imported for pyET
|
||||
def test_correct_import_pyET(self):
|
||||
self.assertEqual(pyET.Element.__module__, 'xml.etree.ElementTree')
|
||||
self.assertEqual(pyET.SubElement.__module__, 'xml.etree.ElementTree')
|
||||
# The type of methods defined in Python code is types.FunctionType,
|
||||
# while the type of methods defined inside _elementtree is
|
||||
# <class 'wrapper_descriptor'>
|
||||
self.assertIsInstance(pyET.Element.__init__, types.FunctionType)
|
||||
self.assertIsInstance(pyET.XMLParser.__init__, types.FunctionType)
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue