| 1 | n/a | from . import util as source_util |
|---|
| 2 | n/a | |
|---|
| 3 | n/a | from importlib import machinery |
|---|
| 4 | n/a | import imp |
|---|
| 5 | n/a | import unittest |
|---|
| 6 | n/a | |
|---|
| 7 | n/a | |
|---|
| 8 | n/a | class PathHookTest(unittest.TestCase): |
|---|
| 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 machinery.FileFinder.path_hook((machinery.SourceFileLoader, |
|---|
| 14 | n/a | machinery.SOURCE_SUFFIXES, True)) |
|---|
| 15 | n/a | |
|---|
| 16 | n/a | def test_success(self): |
|---|
| 17 | n/a | with source_util.create_modules('dummy') as mapping: |
|---|
| 18 | n/a | self.assertTrue(hasattr(self.path_hook()(mapping['.root']), |
|---|
| 19 | n/a | 'find_module')) |
|---|
| 20 | n/a | |
|---|
| 21 | n/a | def test_empty_string(self): |
|---|
| 22 | n/a | # The empty string represents the cwd. |
|---|
| 23 | n/a | self.assertTrue(hasattr(self.path_hook()(''), 'find_module')) |
|---|
| 24 | n/a | |
|---|
| 25 | n/a | |
|---|
| 26 | n/a | def test_main(): |
|---|
| 27 | n/a | from test.support import run_unittest |
|---|
| 28 | n/a | run_unittest(PathHookTest) |
|---|
| 29 | n/a | |
|---|
| 30 | n/a | |
|---|
| 31 | n/a | if __name__ == '__main__': |
|---|
| 32 | n/a | test_main() |
|---|