cpython/Lib/importlib/test/source/test_path_hook.py
Brett Cannon fd0741555b Issue #2377: Make importlib the implementation of __import__().
importlib._bootstrap is now frozen into Python/importlib.h and stored
as _frozen_importlib in sys.modules. Py_Initialize() loads the frozen
code along with sys and imp and then uses _frozen_importlib._install()
to set builtins.__import__() w/ _frozen_importlib.__import__().
2012-04-14 14:10:13 -04:00

27 lines
686 B
Python

from . import util as source_util
from importlib import _bootstrap
import unittest
class PathHookTest(unittest.TestCase):
"""Test the path hook for source."""
def test_success(self):
with source_util.create_modules('dummy') as mapping:
self.assertTrue(hasattr(_bootstrap._file_path_hook(mapping['.root']),
'find_module'))
def test_empty_string(self):
# The empty string represents the cwd.
self.assertTrue(hasattr(_bootstrap._file_path_hook(''), 'find_module'))
def test_main():
from test.support import run_unittest
run_unittest(PathHookTest)
if __name__ == '__main__':
test_main()