2013-11-08 15:25:37 -04:00
|
|
|
from .. import util
|
2009-02-01 00:00:05 -04:00
|
|
|
from . import util as source_util
|
2012-04-14 15:10:13 -03:00
|
|
|
|
2013-11-08 15:25:37 -04:00
|
|
|
machinery = util.import_importlib('importlib.machinery')
|
|
|
|
|
2009-01-17 20:24:28 -04:00
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
2013-11-08 15:25:37 -04:00
|
|
|
class PathHookTest:
|
2009-01-17 20:24:28 -04:00
|
|
|
|
|
|
|
"""Test the path hook for source."""
|
|
|
|
|
2012-04-22 20:58:33 -03:00
|
|
|
def path_hook(self):
|
2013-11-08 15:25:37 -04:00
|
|
|
return self.machinery.FileFinder.path_hook((self.machinery.SourceFileLoader,
|
|
|
|
self.machinery.SOURCE_SUFFIXES))
|
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
|
|
|
|
2013-11-08 15:25:37 -04:00
|
|
|
Frozen_PathHookTest, Source_PathHooktest = util.test_both(PathHookTest, machinery=machinery)
|
2009-01-17 20:24:28 -04:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2013-11-08 15:25:37 -04:00
|
|
|
unittest.main()
|