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

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

#countcontent
1n/afrom .. import util
2n/a
3n/amachinery = util.import_importlib('importlib.machinery')
4n/a
5n/aimport unittest
6n/a
7n/a
8n/aclass PathHookTest:
9n/a
10n/a """Test the path hook for source."""
11n/a
12n/a def path_hook(self):
13n/a return self.machinery.FileFinder.path_hook((self.machinery.SourceFileLoader,
14n/a self.machinery.SOURCE_SUFFIXES))
15n/a
16n/a def test_success(self):
17n/a with util.create_modules('dummy') as mapping:
18n/a self.assertTrue(hasattr(self.path_hook()(mapping['.root']),
19n/a 'find_spec'))
20n/a
21n/a def test_success_legacy(self):
22n/a with util.create_modules('dummy') as mapping:
23n/a self.assertTrue(hasattr(self.path_hook()(mapping['.root']),
24n/a 'find_module'))
25n/a
26n/a def test_empty_string(self):
27n/a # The empty string represents the cwd.
28n/a self.assertTrue(hasattr(self.path_hook()(''), 'find_spec'))
29n/a
30n/a def test_empty_string_legacy(self):
31n/a # The empty string represents the cwd.
32n/a self.assertTrue(hasattr(self.path_hook()(''), 'find_module'))
33n/a
34n/a
35n/a(Frozen_PathHookTest,
36n/a Source_PathHooktest
37n/a ) = util.test_both(PathHookTest, machinery=machinery)
38n/a
39n/a
40n/aif __name__ == '__main__':
41n/a unittest.main()