(root)/
Python-3.12.0/
Lib/
test/
test_importlib/
extension/
test_path_hook.py
       1  from test.test_importlib import util
       2  
       3  machinery = util.import_importlib('importlib.machinery')
       4  
       5  import unittest
       6  
       7  
       8  class ESC[4;38;5;81mPathHookTests:
       9  
      10      """Test the path hook for extension modules."""
      11      # XXX Should it only succeed for pre-existing directories?
      12      # XXX Should it only work for directories containing an extension module?
      13  
      14      def hook(self, entry):
      15          return self.machinery.FileFinder.path_hook(
      16                  (self.machinery.ExtensionFileLoader,
      17                   self.machinery.EXTENSION_SUFFIXES))(entry)
      18  
      19      def test_success(self):
      20          # Path hook should handle a directory where a known extension module
      21          # exists.
      22          self.assertTrue(hasattr(self.hook(util.EXTENSIONS.path), 'find_spec'))
      23  
      24  
      25  (Frozen_PathHooksTests,
      26   Source_PathHooksTests
      27   ) = util.test_both(PathHookTests, machinery=machinery)
      28  
      29  
      30  if __name__ == '__main__':
      31      unittest.main()