mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Issue #21099: Switch applicable importlib tests to use PEP 451 API.
This commit is contained in:
parent
3fa86a0612
commit
228ab1ff6b
8 changed files with 108 additions and 38 deletions
|
@ -217,7 +217,7 @@ class SimpleTest(abc.LoaderTests):
|
|||
# PEP 302
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter('ignore', DeprecationWarning)
|
||||
mod = loader.load_module('_temp') # XXX
|
||||
mod = loader.load_module('_temp')
|
||||
# Sanity checks.
|
||||
self.assertEqual(mod.__cached__, compiled)
|
||||
self.assertEqual(mod.x, 5)
|
||||
|
@ -245,12 +245,7 @@ class SimpleTest(abc.LoaderTests):
|
|||
class BadBytecodeTest:
|
||||
|
||||
def import_(self, file, module_name):
|
||||
loader = self.loader(module_name, file)
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter('ignore', DeprecationWarning)
|
||||
# XXX Change to use exec_module().
|
||||
module = loader.load_module(module_name)
|
||||
self.assertIn(module_name, sys.modules)
|
||||
raise NotImplementedError
|
||||
|
||||
def manipulate_bytecode(self, name, mapping, manipulator, *,
|
||||
del_source=False):
|
||||
|
|
|
@ -16,9 +16,18 @@ class PathHookTest:
|
|||
def test_success(self):
|
||||
with util.create_modules('dummy') as mapping:
|
||||
self.assertTrue(hasattr(self.path_hook()(mapping['.root']),
|
||||
'find_module'))
|
||||
'find_spec'))
|
||||
|
||||
def test_success_legacy(self):
|
||||
with util.create_modules('dummy') as mapping:
|
||||
self.assertTrue(hasattr(self.path_hook()(mapping['.root']),
|
||||
'find_module'))
|
||||
|
||||
def test_empty_string(self):
|
||||
# The empty string represents the cwd.
|
||||
self.assertTrue(hasattr(self.path_hook()(''), 'find_spec'))
|
||||
|
||||
def test_empty_string_legacy(self):
|
||||
# The empty string represents the cwd.
|
||||
self.assertTrue(hasattr(self.path_hook()(''), 'find_module'))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue