2013-10-25 16:39:02 -03:00
|
|
|
from .. import util as test_util
|
2009-02-06 22:06:43 -04:00
|
|
|
from . import util
|
2009-01-17 20:24:28 -04:00
|
|
|
|
2013-10-25 16:39:02 -03:00
|
|
|
machinery = test_util.import_importlib('importlib.machinery')
|
|
|
|
|
2009-01-17 20:24:28 -04:00
|
|
|
import collections
|
|
|
|
import sys
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
2013-10-25 16:39:02 -03:00
|
|
|
class PathHookTests:
|
2009-01-17 20:24:28 -04: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 16:39:02 -03:00
|
|
|
return self.machinery.FileFinder.path_hook(
|
|
|
|
(self.machinery.ExtensionFileLoader,
|
|
|
|
self.machinery.EXTENSION_SUFFIXES))(entry)
|
2009-01-17 20:24:28 -04:00
|
|
|
|
|
|
|
def test_success(self):
|
|
|
|
# Path hook should handle a directory where a known extension module
|
|
|
|
# exists.
|
2009-06-30 20:06:06 -03:00
|
|
|
self.assertTrue(hasattr(self.hook(util.PATH), 'find_module'))
|
2009-01-17 20:24:28 -04:00
|
|
|
|
2013-10-25 16:39:02 -03:00
|
|
|
Frozen_PathHooksTests, Source_PathHooksTests = test_util.test_both(
|
|
|
|
PathHookTests, machinery=machinery)
|
2009-01-17 20:24:28 -04:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2013-10-25 16:39:02 -03:00
|
|
|
unittest.main()
|