Debian Codegraph @

Lib/test/test_importlib/source/test_path_hook.py

raw
1 from test.test_importlib import util
2
3 machinery = util.import_importlib('importlib.machinery')
4
5 import unittest
6
7
8 class PathHookTest:
9
10 """Test the path hook for source."""
11
12 def path_hook(self):
13 return self.machinery.FileFinder.path_hook((self.machinery.SourceFileLoader,
14 self.machinery.SOURCE_SUFFIXES))
15
16 def test_success(self):
17 with util.create_modules('dummy') as mapping:
18 self.assertHasAttr(self.path_hook()(mapping['.root']),
19 'find_spec')
20
21 def test_empty_string(self):
22 # The empty string represents the cwd.
23 self.assertHasAttr(self.path_hook()(''), 'find_spec')
24
25
26 (Frozen_PathHookTest,
27 Source_PathHooktest
28 ) = util.test_both(PathHookTest, machinery=machinery)
29
30
31 if __name__ == '__main__':
32 unittest.main()