bpo-42135: Deprecate implementations of find_module() and find_loader() (GH-25169)

This commit is contained in:
Brett Cannon 2021-04-06 08:56:57 -07:00 committed by GitHub
parent efccff9ac8
commit 57c6cb5100
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 3821 additions and 3653 deletions

View file

@ -4,6 +4,7 @@ from .. import util
machinery = util.import_importlib('importlib.machinery')
import unittest
import warnings
class FindSpecTests(abc.FinderTests):
@ -49,7 +50,9 @@ class FinderTests(abc.FinderTests):
def find(self, name, path=None):
finder = self.machinery.FrozenImporter
return finder.find_module(name, path)
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
return finder.find_module(name, path)
def test_module(self):
name = '__hello__'

View file

@ -78,7 +78,7 @@ class ExecModuleTests(abc.LoaderTests):
test_state_after_failure = None
def test_unloadable(self):
assert self.machinery.FrozenImporter.find_module('_not_real') is None
assert self.machinery.FrozenImporter.find_spec('_not_real') is None
with self.assertRaises(ImportError) as cm:
self.exec_module('_not_real')
self.assertEqual(cm.exception.name, '_not_real')