test_path_hook.py 864 Bytes
Newer Older
1
from .. import util
2

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

5 6 7
import unittest


8
class PathHookTests:
9 10 11 12 13 14

    """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):
15 16 17
        return self.machinery.FileFinder.path_hook(
                (self.machinery.ExtensionFileLoader,
                 self.machinery.EXTENSION_SUFFIXES))(entry)
18 19 20 21

    def test_success(self):
        # Path hook should handle a directory where a known extension module
        # exists.
22
        self.assertTrue(hasattr(self.hook(util.EXTENSIONS.path), 'find_module'))
23

24 25 26 27

(Frozen_PathHooksTests,
 Source_PathHooksTests
 ) = util.test_both(PathHookTests, machinery=machinery)
28 29 30


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