summaryrefslogtreecommitdiff
path: root/Lib/test/test_xml_etree_c.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2020-06-10 09:01:25 -0700
committerGitHub <noreply@github.com>2020-06-10 18:01:25 +0200
commit3b97d1becbe08cf56c58d9c740a4622cbf6285fd (patch)
treeda5877514b48e8d90edd19898371d3e25ef50f59 /Lib/test/test_xml_etree_c.py
parentd55ed7b10794b6ee6a04a564e6d714368d520c15 (diff)
downloadcpython-git-3b97d1becbe08cf56c58d9c740a4622cbf6285fd.tar.gz
bpo-36543: Revert "bpo-36543: Remove the xml.etree.cElementTree module." (GH-20117) (GH-20780)
* Revert "bpo-36543: Remove the xml.etree.cElementTree module. (GH-19108)" This reverts commit b33e52511a59c6da7132c226b7f7489b092a33eb. (cherry picked from commit ec88e1bca81a167e6d5c0ac635e22f84298cb1df)
Diffstat (limited to 'Lib/test/test_xml_etree_c.py')
-rw-r--r--Lib/test/test_xml_etree_c.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_xml_etree_c.py b/Lib/test/test_xml_etree_c.py
index 7437e13d06..e26e1714a5 100644
--- a/Lib/test/test_xml_etree_c.py
+++ b/Lib/test/test_xml_etree_c.py
@@ -8,6 +8,9 @@ import unittest
cET = import_fresh_module('xml.etree.ElementTree',
fresh=['_elementtree'])
+cET_alias = import_fresh_module('xml.etree.cElementTree',
+ fresh=['_elementtree', 'xml.etree'],
+ deprecated=True)
@unittest.skipUnless(cET, 'requires _elementtree')
@@ -168,6 +171,14 @@ class MiscTests(unittest.TestCase):
@unittest.skipUnless(cET, 'requires _elementtree')
+class TestAliasWorking(unittest.TestCase):
+ # Test that the cET alias module is alive
+ def test_alias_working(self):
+ e = cET_alias.Element('foo')
+ self.assertEqual(e.tag, 'foo')
+
+
+@unittest.skipUnless(cET, 'requires _elementtree')
@support.cpython_only
class TestAcceleratorImported(unittest.TestCase):
# Test that the C accelerator was imported, as expected
@@ -175,6 +186,9 @@ class TestAcceleratorImported(unittest.TestCase):
# SubElement is a function so it retains _elementtree as its module.
self.assertEqual(cET.SubElement.__module__, '_elementtree')
+ def test_correct_import_cET_alias(self):
+ self.assertEqual(cET_alias.SubElement.__module__, '_elementtree')
+
def test_parser_comes_from_C(self):
# The type of methods defined in Python code is types.FunctionType,
# while the type of methods defined inside _elementtree is
@@ -214,6 +228,7 @@ def test_main():
# Run the tests specific to the C implementation
support.run_unittest(
MiscTests,
+ TestAliasWorking,
TestAcceleratorImported,
SizeofTest,
)