diff options
author | Brett Cannon <brett@python.org> | 2012-05-11 16:58:42 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2012-05-11 16:58:42 (GMT) |
commit | cb66eb0deca1d5cd232f97c76a215ecaab958d30 (patch) | |
tree | f38497a2e61cf8be225c4e7394961703cea5f66c /Lib/importlib/test/source | |
parent | 810c64df8f8bf70a2cb7a626004185616cb88213 (diff) | |
download | cpython-cb66eb0deca1d5cd232f97c76a215ecaab958d30.zip cpython-cb66eb0deca1d5cd232f97c76a215ecaab958d30.tar.gz cpython-cb66eb0deca1d5cd232f97c76a215ecaab958d30.tar.bz2 |
Issue #13959: Deprecate imp.get_suffixes() for new attributes on
importlib.machinery that provide the suffix details for import.
The attributes were not put on imp so as to compartmentalize
everything importlib needs for setting up imports in
importlib.machinery.
This also led to an indirect deprecation of inspect.getmoduleinfo() as
it directly returned imp.get_suffix's returned tuple which no longer
makes sense.
Diffstat (limited to 'Lib/importlib/test/source')
-rw-r--r-- | Lib/importlib/test/source/test_case_sensitivity.py | 11 | ||||
-rw-r--r-- | Lib/importlib/test/source/test_finder.py | 20 | ||||
-rw-r--r-- | Lib/importlib/test/source/test_path_hook.py | 6 |
3 files changed, 19 insertions, 18 deletions
diff --git a/Lib/importlib/test/source/test_case_sensitivity.py b/Lib/importlib/test/source/test_case_sensitivity.py index fade25f..21a4378 100644 --- a/Lib/importlib/test/source/test_case_sensitivity.py +++ b/Lib/importlib/test/source/test_case_sensitivity.py @@ -1,5 +1,6 @@ """Test case-sensitivity (PEP 235).""" from importlib import _bootstrap +from importlib import machinery from .. import util from . import util as source_util import imp @@ -20,12 +21,12 @@ class CaseSensitivityTest(unittest.TestCase): assert name != name.lower() def find(self, path): - finder = _bootstrap.FileFinder(path, - (_bootstrap.SourceFileLoader, - _bootstrap._SOURCE_SUFFIXES, + finder = machinery.FileFinder(path, + (machinery.SourceFileLoader, + machinery.SOURCE_SUFFIXES, True), - (_bootstrap.SourcelessFileLoader, - [_bootstrap._BYTECODE_SUFFIX], + (machinery.SourcelessFileLoader, + machinery.BYTECODE_SUFFIXES, True)) return finder.find_module(self.name) diff --git a/Lib/importlib/test/source/test_finder.py b/Lib/importlib/test/source/test_finder.py index 45b804f..bbe0163 100644 --- a/Lib/importlib/test/source/test_finder.py +++ b/Lib/importlib/test/source/test_finder.py @@ -1,7 +1,7 @@ from .. import abc from . import util as source_util -from importlib import _bootstrap +from importlib import machinery import errno import imp import os @@ -36,11 +36,11 @@ class FinderTests(abc.FinderTests): """ def import_(self, root, module): - loader_details = [(_bootstrap.SourceFileLoader, - _bootstrap._SOURCE_SUFFIXES, True), - (_bootstrap.SourcelessFileLoader, - [_bootstrap._BYTECODE_SUFFIX], True)] - finder = _bootstrap.FileFinder(root, *loader_details) + loader_details = [(machinery.SourceFileLoader, + machinery.SOURCE_SUFFIXES, True), + (machinery.SourcelessFileLoader, + machinery.BYTECODE_SUFFIXES, True)] + finder = machinery.FileFinder(root, *loader_details) return finder.find_module(module) def run_test(self, test, create=None, *, compile_=None, unlink=None): @@ -138,8 +138,8 @@ class FinderTests(abc.FinderTests): def test_empty_string_for_dir(self): # The empty string from sys.path means to search in the cwd. - finder = _bootstrap.FileFinder('', (_bootstrap.SourceFileLoader, - _bootstrap._SOURCE_SUFFIXES, True)) + finder = machinery.FileFinder('', (machinery.SourceFileLoader, + machinery.SOURCE_SUFFIXES, True)) with open('mod.py', 'w') as file: file.write("# test file for importlib") try: @@ -150,8 +150,8 @@ class FinderTests(abc.FinderTests): def test_invalidate_caches(self): # invalidate_caches() should reset the mtime. - finder = _bootstrap.FileFinder('', (_bootstrap.SourceFileLoader, - _bootstrap._SOURCE_SUFFIXES, True)) + finder = machinery.FileFinder('', (machinery.SourceFileLoader, + machinery.SOURCE_SUFFIXES, True)) finder._path_mtime = 42 finder.invalidate_caches() self.assertEqual(finder._path_mtime, -1) diff --git a/Lib/importlib/test/source/test_path_hook.py b/Lib/importlib/test/source/test_path_hook.py index df69b4d..54c0699 100644 --- a/Lib/importlib/test/source/test_path_hook.py +++ b/Lib/importlib/test/source/test_path_hook.py @@ -1,6 +1,6 @@ from . import util as source_util -from importlib import _bootstrap +from importlib import machinery import imp import unittest @@ -10,8 +10,8 @@ class PathHookTest(unittest.TestCase): """Test the path hook for source.""" def path_hook(self): - return _bootstrap.FileFinder.path_hook((_bootstrap.SourceFileLoader, - _bootstrap._SOURCE_SUFFIXES, True)) + return machinery.FileFinder.path_hook((machinery.SourceFileLoader, + machinery.SOURCE_SUFFIXES, True)) def test_success(self): with source_util.create_modules('dummy') as mapping: |