2009-02-01 04:00:05 +00:00
|
|
|
from . import util as source_util
|
2012-04-14 14:10:13 -04:00
|
|
|
|
2012-05-11 12:58:42 -04:00
|
|
|
from importlib import machinery
|
2012-04-22 19:58:33 -04:00
|
|
|
import imp
|
2009-01-18 00:24:28 +00:00
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
|
|
class PathHookTest(unittest.TestCase):
|
|
|
|
|
|
|
|
"""Test the path hook for source."""
|
|
|
|
|
2012-04-22 19:58:33 -04:00
|
|
|
def path_hook(self):
|
2012-05-11 12:58:42 -04:00
|
|
|
return machinery.FileFinder.path_hook((machinery.SourceFileLoader,
|
|
|
|
machinery.SOURCE_SUFFIXES, True))
|
2012-04-22 19:58:33 -04:00
|
|
|
|
2009-01-18 00:24:28 +00:00
|
|
|
def test_success(self):
|
2009-02-01 04:00:05 +00:00
|
|
|
with source_util.create_modules('dummy') as mapping:
|
2012-04-22 19:58:33 -04:00
|
|
|
self.assertTrue(hasattr(self.path_hook()(mapping['.root']),
|
2009-01-18 00:24:28 +00:00
|
|
|
'find_module'))
|
|
|
|
|
2010-07-03 22:18:47 +00:00
|
|
|
def test_empty_string(self):
|
|
|
|
# The empty string represents the cwd.
|
2012-04-22 19:58:33 -04:00
|
|
|
self.assertTrue(hasattr(self.path_hook()(''), 'find_module'))
|
2010-07-03 22:18:47 +00:00
|
|
|
|
2009-01-18 00:24:28 +00:00
|
|
|
|
|
|
|
def test_main():
|
|
|
|
from test.support import run_unittest
|
|
|
|
run_unittest(PathHookTest)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
test_main()
|