ยปCore Development>Code coverage>Lib/importlib/test/source/test_path_hook.py

Python code coverage for Lib/importlib/test/source/test_path_hook.py

#countcontent
1n/afrom . import util as source_util
2n/a
3n/afrom importlib import machinery
4n/aimport imp
5n/aimport unittest
6n/a
7n/a
8n/aclass PathHookTest(unittest.TestCase):
9n/a
10n/a """Test the path hook for source."""
11n/a
12n/a def path_hook(self):
13n/a return machinery.FileFinder.path_hook((machinery.SourceFileLoader,
14n/a machinery.SOURCE_SUFFIXES, True))
15n/a
16n/a def test_success(self):
17n/a with source_util.create_modules('dummy') as mapping:
18n/a self.assertTrue(hasattr(self.path_hook()(mapping['.root']),
19n/a 'find_module'))
20n/a
21n/a def test_empty_string(self):
22n/a # The empty string represents the cwd.
23n/a self.assertTrue(hasattr(self.path_hook()(''), 'find_module'))
24n/a
25n/a
26n/adef test_main():
27n/a from test.support import run_unittest
28n/a run_unittest(PathHookTest)
29n/a
30n/a
31n/aif __name__ == '__main__':
32n/a test_main()