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