diff options
Diffstat (limited to 'Lib/test/test_importlib/source/test_path_hook.py')
-rw-r--r-- | Lib/test/test_importlib/source/test_path_hook.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/Lib/test/test_importlib/source/test_path_hook.py b/Lib/test/test_importlib/source/test_path_hook.py new file mode 100644 index 0000000000..6a78792f07 --- /dev/null +++ b/Lib/test/test_importlib/source/test_path_hook.py @@ -0,0 +1,32 @@ +from . import util as source_util + +from importlib import machinery +import imp +import unittest + + +class PathHookTest(unittest.TestCase): + + """Test the path hook for source.""" + + def path_hook(self): + return machinery.FileFinder.path_hook((machinery.SourceFileLoader, + machinery.SOURCE_SUFFIXES)) + + 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() |