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