11import importlib
2+ from importlib import _bootstrap
23from .. import abc
34from . import util as source_util
45
@@ -19,7 +20,8 @@ class SimpleTest(unittest.TestCase):
1920 # [basic]
2021 def test_module (self ):
2122 with source_util .create_modules ('_temp' ) as mapping :
22- loader = importlib .PyPycFileLoader ('_temp' , mapping ['_temp' ], False )
23+ loader = _bootstrap ._PyPycFileLoader ('_temp' , mapping ['_temp' ],
24+ False )
2325 module = loader .load_module ('_temp' )
2426 self .assert_ ('_temp' in sys .modules )
2527 check = {'__name__' : '_temp' , '__file__' : mapping ['_temp' ],
@@ -29,8 +31,9 @@ def test_module(self):
2931
3032 def test_package (self ):
3133 with source_util .create_modules ('_pkg.__init__' ) as mapping :
32- loader = importlib .PyPycFileLoader ('_pkg' , mapping ['_pkg.__init__' ],
33- True )
34+ loader = _bootstrap ._PyPycFileLoader ('_pkg' ,
35+ mapping ['_pkg.__init__' ],
36+ True )
3437 module = loader .load_module ('_pkg' )
3538 self .assert_ ('_pkg' in sys .modules )
3639 check = {'__name__' : '_pkg' , '__file__' : mapping ['_pkg.__init__' ],
@@ -42,8 +45,8 @@ def test_package(self):
4245
4346 def test_lacking_parent (self ):
4447 with source_util .create_modules ('_pkg.__init__' , '_pkg.mod' )as mapping :
45- loader = importlib . PyPycFileLoader ('_pkg.mod' , mapping [ '_pkg.mod' ] ,
46- False )
48+ loader = _bootstrap . _PyPycFileLoader ('_pkg.mod' ,
49+ mapping [ '_pkg.mod' ], False )
4750 module = loader .load_module ('_pkg.mod' )
4851 self .assert_ ('_pkg.mod' in sys .modules )
4952 check = {'__name__' : '_pkg.mod' , '__file__' : mapping ['_pkg.mod' ],
@@ -57,7 +60,8 @@ def fake_mtime(self, fxn):
5760
5861 def test_module_reuse (self ):
5962 with source_util .create_modules ('_temp' ) as mapping :
60- loader = importlib .PyPycFileLoader ('_temp' , mapping ['_temp' ], False )
63+ loader = _bootstrap ._PyPycFileLoader ('_temp' , mapping ['_temp' ],
64+ False )
6165 module = loader .load_module ('_temp' )
6266 module_id = id (module )
6367 module_dict_id = id (module .__dict__ )
@@ -87,7 +91,8 @@ def test_state_after_failure(self):
8791 setattr (orig_module , attr , value )
8892 with open (mapping [name ], 'w' ) as file :
8993 file .write ('+++ bad syntax +++' )
90- loader = importlib .PyPycFileLoader ('_temp' , mapping ['_temp' ], False )
94+ loader = _bootstrap ._PyPycFileLoader ('_temp' , mapping ['_temp' ],
95+ False )
9196 self .assertRaises (SyntaxError , loader .load_module , name )
9297 for attr in attributes :
9398 self .assertEqual (getattr (orig_module , attr ), value )
@@ -97,7 +102,8 @@ def test_bad_syntax(self):
97102 with source_util .create_modules ('_temp' ) as mapping :
98103 with open (mapping ['_temp' ], 'w' ) as file :
99104 file .write ('=' )
100- loader = importlib .PyPycFileLoader ('_temp' , mapping ['_temp' ], False )
105+ loader = _bootstrap ._PyPycFileLoader ('_temp' , mapping ['_temp' ],
106+ False )
101107 self .assertRaises (SyntaxError , loader .load_module , '_temp' )
102108 self .assert_ ('_temp' not in sys .modules )
103109
@@ -116,7 +122,7 @@ class BadBytecodeTest(unittest.TestCase):
116122 """
117123
118124 def import_ (self , file , module_name ):
119- loader = importlib . PyPycFileLoader (module_name , file , False )
125+ loader = _bootstrap . _PyPycFileLoader (module_name , file , False )
120126 module = loader .load_module (module_name )
121127 self .assert_ (module_name in sys .modules )
122128
0 commit comments