88
99cET = import_fresh_module ('xml.etree.ElementTree' ,
1010 fresh = ['_elementtree' ])
11+ cET_alias = import_fresh_module ('xml.etree.cElementTree' ,
12+ fresh = ['_elementtree' , 'xml.etree' ],
13+ deprecated = True )
1114
1215
1316@unittest .skipUnless (cET , 'requires _elementtree' )
@@ -167,6 +170,14 @@ def test_xmlpullparser_leaks(self):
167170 support .gc_collect ()
168171
169172
173+ @unittest .skipUnless (cET , 'requires _elementtree' )
174+ class TestAliasWorking (unittest .TestCase ):
175+ # Test that the cET alias module is alive
176+ def test_alias_working (self ):
177+ e = cET_alias .Element ('foo' )
178+ self .assertEqual (e .tag , 'foo' )
179+
180+
170181@unittest .skipUnless (cET , 'requires _elementtree' )
171182@support .cpython_only
172183class TestAcceleratorImported (unittest .TestCase ):
@@ -175,6 +186,9 @@ def test_correct_import_cET(self):
175186 # SubElement is a function so it retains _elementtree as its module.
176187 self .assertEqual (cET .SubElement .__module__ , '_elementtree' )
177188
189+ def test_correct_import_cET_alias (self ):
190+ self .assertEqual (cET_alias .SubElement .__module__ , '_elementtree' )
191+
178192 def test_parser_comes_from_C (self ):
179193 # The type of methods defined in Python code is types.FunctionType,
180194 # while the type of methods defined inside _elementtree is
@@ -214,6 +228,7 @@ def test_main():
214228 # Run the tests specific to the C implementation
215229 support .run_unittest (
216230 MiscTests ,
231+ TestAliasWorking ,
217232 TestAcceleratorImported ,
218233 SizeofTest ,
219234 )
0 commit comments