test_path_hook.py 833 Bytes
Newer Older
1
from importlib import machinery
2
from . import util
3 4 5 6 7 8 9 10 11 12 13 14 15 16

import collections
import imp
import sys
import unittest


class PathHookTests(unittest.TestCase):

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

    def test_success(self):
        # Path hook should handle a directory where a known extension module
        # exists.
23
        self.assertTrue(hasattr(self.hook(util.PATH), 'find_module'))
24 25 26 27 28 29 30 31 32


def test_main():
    from test.support import run_unittest
    run_unittest(PathHookTests)


if __name__ == '__main__':
    test_main()