5
5
import py_compile
6
6
import sys
7
7
from test import support
8
+ from test .support import import_helper
9
+ from test .support import os_helper
8
10
from test .support import script_helper
9
11
import unittest
10
12
import warnings
@@ -107,8 +109,8 @@ def test_issue3594(self):
107
109
self .assertEqual (file .encoding , 'cp1252' )
108
110
finally :
109
111
del sys .path [0 ]
110
- support .unlink (temp_mod_name + '.py' )
111
- support .unlink (temp_mod_name + '.pyc' )
112
+ os_helper .unlink (temp_mod_name + '.py' )
113
+ os_helper .unlink (temp_mod_name + '.pyc' )
112
114
113
115
def test_issue5604 (self ):
114
116
# Test cannot cover imp.load_compiled function.
@@ -192,10 +194,10 @@ def test_issue5604(self):
192
194
finally :
193
195
del sys .path [0 ]
194
196
for ext in ('.py' , '.pyc' ):
195
- support .unlink (temp_mod_name + ext )
196
- support .unlink (init_file_name + ext )
197
- support .rmtree (test_package_name )
198
- support .rmtree ('__pycache__' )
197
+ os_helper .unlink (temp_mod_name + ext )
198
+ os_helper .unlink (init_file_name + ext )
199
+ os_helper .rmtree (test_package_name )
200
+ os_helper .rmtree ('__pycache__' )
199
201
200
202
def test_issue9319 (self ):
201
203
path = os .path .dirname (__file__ )
@@ -204,7 +206,7 @@ def test_issue9319(self):
204
206
205
207
def test_load_from_source (self ):
206
208
# Verify that the imp module can correctly load and find .py files
207
- # XXX (ncoghlan): It would be nice to use support .CleanImport
209
+ # XXX (ncoghlan): It would be nice to use import_helper .CleanImport
208
210
# here, but that breaks because the os module registers some
209
211
# handlers in copy_reg on import. Since CleanImport doesn't
210
212
# revert that registration, the module is left in a broken
@@ -213,7 +215,7 @@ def test_load_from_source(self):
213
215
# workaround
214
216
orig_path = os .path
215
217
orig_getenv = os .getenv
216
- with support .EnvironmentVarGuard ():
218
+ with os_helper .EnvironmentVarGuard ():
217
219
x = imp .find_module ("os" )
218
220
self .addCleanup (x [0 ].close )
219
221
new_os = imp .load_module ("os" , * x )
@@ -299,11 +301,11 @@ def test_issue24748_load_module_skips_sys_modules_check(self):
299
301
@unittest .skipIf (sys .dont_write_bytecode ,
300
302
"test meaningful only when writing bytecode" )
301
303
def test_bug7732 (self ):
302
- with support .temp_cwd ():
303
- source = support .TESTFN + '.py'
304
+ with os_helper .temp_cwd ():
305
+ source = os_helper .TESTFN + '.py'
304
306
os .mkdir (source )
305
307
self .assertRaisesRegex (ImportError , '^No module' ,
306
- imp .find_module , support .TESTFN , ["." ])
308
+ imp .find_module , os_helper .TESTFN , ["." ])
307
309
308
310
def test_multiple_calls_to_get_data (self ):
309
311
# Issue #18755: make sure multiple calls to get_data() can succeed.
@@ -364,7 +366,7 @@ def test_pyc_invalidation_mode_from_cmdline(self):
364
366
365
367
def test_find_and_load_checked_pyc (self ):
366
368
# issue 34056
367
- with support .temp_cwd ():
369
+ with os_helper .temp_cwd ():
368
370
with open ('mymod.py' , 'wb' ) as fp :
369
371
fp .write (b'x = 42\n ' )
370
372
py_compile .compile (
@@ -383,24 +385,24 @@ class ReloadTests(unittest.TestCase):
383
385
reload()."""
384
386
385
387
def test_source (self ):
386
- # XXX (ncoghlan): It would be nice to use test.support .CleanImport
388
+ # XXX (ncoghlan): It would be nice to use test.import_helper .CleanImport
387
389
# here, but that breaks because the os module registers some
388
390
# handlers in copy_reg on import. Since CleanImport doesn't
389
391
# revert that registration, the module is left in a broken
390
392
# state after reversion. Reinitialising the module contents
391
393
# and just reverting os.environ to its previous state is an OK
392
394
# workaround
393
- with support .EnvironmentVarGuard ():
395
+ with os_helper .EnvironmentVarGuard ():
394
396
import os
395
397
imp .reload (os )
396
398
397
399
def test_extension (self ):
398
- with support .CleanImport ('time' ):
400
+ with import_helper .CleanImport ('time' ):
399
401
import time
400
402
imp .reload (time )
401
403
402
404
def test_builtin (self ):
403
- with support .CleanImport ('marshal' ):
405
+ with import_helper .CleanImport ('marshal' ):
404
406
import marshal
405
407
imp .reload (marshal )
406
408
@@ -443,10 +445,10 @@ def test_source_from_cache(self):
443
445
444
446
445
447
class NullImporterTests (unittest .TestCase ):
446
- @unittest .skipIf (support .TESTFN_UNENCODABLE is None ,
448
+ @unittest .skipIf (os_helper .TESTFN_UNENCODABLE is None ,
447
449
"Need an undecodeable filename" )
448
450
def test_unencodeable (self ):
449
- name = support .TESTFN_UNENCODABLE
451
+ name = os_helper .TESTFN_UNENCODABLE
450
452
os .mkdir (name )
451
453
try :
452
454
self .assertRaises (ImportError , imp .NullImporter , name )
0 commit comments