cpython/Lib/importlib/test/source/test_path_hook.py
Brett Cannon 2657df4744 Issue #13959: Re-implement imp.get_suffixes() in Lib/imp.py.
This introduces a new function, imp.extension_suffixes(), which is
currently undocumented. That is forthcoming once issue #14657 is
resolved and how to expose file suffixes is decided.
2012-05-04 15:20:40 -04:00

32 lines
828 B
Python

from . import util as source_util
from importlib import _bootstrap
import imp
import unittest
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))
def test_success(self):
with source_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_module'))
def test_main():
from test.support import run_unittest
run_unittest(PathHookTest)
if __name__ == '__main__':
test_main()