mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Issue #15502: Finish bringing importlib.abc in line with the current
state of the import system. Also make importlib.invalidate_caches() work with sys.meta_path instead of sys.path_importer_cache to completely separate the path-based import system from the overall import system. Patch by Eric Snow.
This commit is contained in:
parent
2d6266d5f1
commit
f4dc9204cc
8 changed files with 1294 additions and 1207 deletions
|
@ -36,11 +36,13 @@ class MetaPathFinder(InheritanceTests, unittest.TestCase):
|
|||
subclasses = [machinery.BuiltinImporter, machinery.FrozenImporter,
|
||||
machinery.PathFinder, machinery.WindowsRegistryFinder]
|
||||
|
||||
|
||||
class PathEntryFinder(InheritanceTests, unittest.TestCase):
|
||||
|
||||
superclasses = [abc.Finder]
|
||||
subclasses = [machinery.FileFinder]
|
||||
|
||||
|
||||
class Loader(InheritanceTests, unittest.TestCase):
|
||||
|
||||
subclasses = [abc.PyLoader]
|
||||
|
|
|
@ -148,11 +148,15 @@ class InvalidateCacheTests(unittest.TestCase):
|
|||
self.called = True
|
||||
|
||||
key = 'gobledeegook'
|
||||
ins = InvalidatingNullFinder()
|
||||
sys.path_importer_cache[key] = ins
|
||||
meta_ins = InvalidatingNullFinder()
|
||||
path_ins = InvalidatingNullFinder()
|
||||
sys.meta_path.insert(0, meta_ins)
|
||||
self.addCleanup(lambda: sys.path_importer_cache.__delitem__(key))
|
||||
sys.path_importer_cache[key] = path_ins
|
||||
self.addCleanup(lambda: sys.meta_path.remove(meta_ins))
|
||||
importlib.invalidate_caches()
|
||||
self.assertTrue(ins.called)
|
||||
self.assertTrue(meta_ins.called)
|
||||
self.assertTrue(path_ins.called)
|
||||
|
||||
def test_method_lacking(self):
|
||||
# There should be no issues if the method is not defined.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue