| 1 | n/a | from importlib import _bootstrap |
|---|
| 2 | n/a | from . import util |
|---|
| 3 | n/a | |
|---|
| 4 | n/a | import collections |
|---|
| 5 | n/a | import imp |
|---|
| 6 | n/a | import sys |
|---|
| 7 | n/a | import unittest |
|---|
| 8 | n/a | |
|---|
| 9 | n/a | |
|---|
| 10 | n/a | class PathHookTests(unittest.TestCase): |
|---|
| 11 | n/a | |
|---|
| 12 | n/a | """Test the path hook for extension modules.""" |
|---|
| 13 | n/a | # XXX Should it only succeed for pre-existing directories? |
|---|
| 14 | n/a | # XXX Should it only work for directories containing an extension module? |
|---|
| 15 | n/a | |
|---|
| 16 | n/a | def hook(self, entry): |
|---|
| 17 | n/a | return _bootstrap.FileFinder.path_hook((_bootstrap.ExtensionFileLoader, |
|---|
| 18 | n/a | imp.extension_suffixes(), False))(entry) |
|---|
| 19 | n/a | |
|---|
| 20 | n/a | def test_success(self): |
|---|
| 21 | n/a | # Path hook should handle a directory where a known extension module |
|---|
| 22 | n/a | # exists. |
|---|
| 23 | n/a | self.assertTrue(hasattr(self.hook(util.PATH), '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(PathHookTests) |
|---|
| 29 | n/a | |
|---|
| 30 | n/a | |
|---|
| 31 | n/a | if __name__ == '__main__': |
|---|
| 32 | n/a | test_main() |
|---|