2022-01-22 19:05:05 +03:00
|
|
|
from test.test_importlib import util
|
2009-01-18 00:24:28 +00:00
|
|
|
|
2014-05-09 14:32:57 -04:00
|
|
|
machinery = util.import_importlib('importlib.machinery')
|
2013-10-25 15:39:02 -04:00
|
|
|
|
2009-01-18 00:24:28 +00:00
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
2024-03-13 13:24:28 -07:00
|
|
|
@unittest.skipIf(util.EXTENSIONS is None or util.EXTENSIONS.filename is None,
|
|
|
|
'dynamic loading not supported or test module not available')
|
2013-10-25 15:39:02 -04:00
|
|
|
class PathHookTests:
|
2009-01-18 00:24:28 +00:00
|
|
|
|
|
|
|
"""Test the path hook for extension modules."""
|
|
|
|
# XXX Should it only succeed for pre-existing directories?
|
|
|
|
# XXX Should it only work for directories containing an extension module?
|
|
|
|
|
|
|
|
def hook(self, entry):
|
2013-10-25 15:39:02 -04:00
|
|
|
return self.machinery.FileFinder.path_hook(
|
|
|
|
(self.machinery.ExtensionFileLoader,
|
|
|
|
self.machinery.EXTENSION_SUFFIXES))(entry)
|
2009-01-18 00:24:28 +00:00
|
|
|
|
|
|
|
def test_success(self):
|
|
|
|
# Path hook should handle a directory where a known extension module
|
|
|
|
# exists.
|
2023-05-03 04:55:22 -07:00
|
|
|
self.assertTrue(hasattr(self.hook(util.EXTENSIONS.path), 'find_spec'))
|
2009-01-18 00:24:28 +00:00
|
|
|
|
2014-05-16 11:40:40 -06:00
|
|
|
|
|
|
|
(Frozen_PathHooksTests,
|
|
|
|
Source_PathHooksTests
|
|
|
|
) = util.test_both(PathHookTests, machinery=machinery)
|
2009-01-18 00:24:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2013-10-25 15:39:02 -04:00
|
|
|
unittest.main()
|