Staging
v0.5.1
https://github.com/python/cpython
Raw File
Tip revision: 44719a771767b43cc0ee1d50c896179c8722a7d7 authored by Larry Hastings on 28 September 2013, 22:51:00 UTC
Version bump to 3.4.0a3.
Tip revision: 44719a7
test_path_hook.py
from . import util as source_util

from importlib import machinery
import unittest


class PathHookTest(unittest.TestCase):

    """Test the path hook for source."""

    def path_hook(self):
        return machinery.FileFinder.path_hook((machinery.SourceFileLoader,
            machinery.SOURCE_SUFFIXES))

    def test_success(self):
        with source_util.create_modules('dummy') as mapping:
            self.assertTrue(hasattr(self.path_hook()(mapping['.root']),
                                 'find_module'))

    def test_empty_string(self):
        # The empty string represents the cwd.
        self.assertTrue(hasattr(self.path_hook()(''), 'find_module'))


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


if __name__ == '__main__':
    test_main()
back to top