8
8
9
9
cET = import_fresh_module ('xml.etree.ElementTree' ,
10
10
fresh = ['_elementtree' ])
11
+ cET_alias = import_fresh_module ('xml.etree.cElementTree' ,
12
+ fresh = ['_elementtree' , 'xml.etree' ],
13
+ deprecated = True )
11
14
12
15
13
16
@unittest .skipUnless (cET , 'requires _elementtree' )
@@ -167,6 +170,14 @@ def test_xmlpullparser_leaks(self):
167
170
support .gc_collect ()
168
171
169
172
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
+
170
181
@unittest .skipUnless (cET , 'requires _elementtree' )
171
182
@support .cpython_only
172
183
class TestAcceleratorImported (unittest .TestCase ):
@@ -175,6 +186,9 @@ def test_correct_import_cET(self):
175
186
# SubElement is a function so it retains _elementtree as its module.
176
187
self .assertEqual (cET .SubElement .__module__ , '_elementtree' )
177
188
189
+ def test_correct_import_cET_alias (self ):
190
+ self .assertEqual (cET_alias .SubElement .__module__ , '_elementtree' )
191
+
178
192
def test_parser_comes_from_C (self ):
179
193
# The type of methods defined in Python code is types.FunctionType,
180
194
# while the type of methods defined inside _elementtree is
@@ -214,6 +228,7 @@ def test_main():
214
228
# Run the tests specific to the C implementation
215
229
support .run_unittest (
216
230
MiscTests ,
231
+ TestAliasWorking ,
217
232
TestAcceleratorImported ,
218
233
SizeofTest ,
219
234
)
0 commit comments