test the path hook for extension modules xxx should it only succeed for preexisting directories xxx should it only work for directories containing an extension module def hookself entry return self machinery filefinder pathhook self machinery extensionfileloader self machinery extensionsuffixesentry def testsuccessself path hook should handle a directory where a known extension module exists self asserttruehasattrself hookutil extensions path findspec frozenpathhookstests sourcepathhookstests util testbothpathhooktests machinerymachinery if name main unittest main 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 path hook should handle a directory where a known extension module exists
from test.test_importlib import util

machinery = util.import_importlib('importlib.machinery')

import unittest


class PathHookTests:

    
    
    

    def hook(self, entry):
        return self.machinery.FileFinder.path_hook(
                (self.machinery.ExtensionFileLoader,
                 self.machinery.EXTENSION_SUFFIXES))(entry)

    def test_success(self):
        
        
        self.assertTrue(hasattr(self.hook(util.EXTENSIONS.path), 'find_spec'))


(Frozen_PathHooksTests,
 Source_PathHooksTests
 ) = util.test_both(PathHookTests, machinery=machinery)


if __name__ == '__main__':
    unittest.main()