| 1 |
from test.test_importlib import util |
| 2 |
|
| 3 |
machinery = util.import_importlib('importlib.machinery') |
| 4 |
|
| 5 |
import unittest |
| 6 |
|
| 7 |
|
| 8 |
@unittest.skipIf(util.EXTENSIONS is None or util.EXTENSIONS.filename is None, |
| 9 |
'dynamic loading not supported or test module not available') |
| 10 |
class PathHookTests: |
| 11 |
|
| 12 |
"""Test the path hook for extension modules.""" |
| 13 |
# XXX Should it only succeed for pre-existing directories? |
| 14 |
# XXX Should it only work for directories containing an extension module? |
| 15 |
|
| 16 |
def hook(self, entry): |
| 17 |
return self.machinery.FileFinder.path_hook( |
| 18 |
(self.machinery.ExtensionFileLoader, |
| 19 |
self.machinery.EXTENSION_SUFFIXES))(entry) |
| 20 |
|
| 21 |
def test_success(self): |
| 22 |
# Path hook should handle a directory where a known extension module |
| 23 |
# exists. |
| 24 |
self.assertHasAttr(self.hook(util.EXTENSIONS.path), 'find_spec') |
| 25 |
|
| 26 |
|
| 27 |
(Frozen_PathHooksTests, |
| 28 |
Source_PathHooksTests |
| 29 |
) = util.test_both(PathHookTests, machinery=machinery) |
| 30 |
|
| 31 |
|
| 32 |
if __name__ == '__main__': |
| 33 |
unittest.main() |