summaryrefslogtreecommitdiffstats
path: root/Lib/importlib/test
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2009-02-05 22:02:03 (GMT)
committerBrett Cannon <bcannon@gmail.com>2009-02-05 22:02:03 (GMT)
commit48f5c4eec6c85b5c91e8d45921afe8d62410239b (patch)
tree97b5277aac39e752d2a4d4d04af44f4ba579ae41 /Lib/importlib/test
parent014bf28ef109302a4254bfd10f25f4526aa0617d (diff)
downloadcpython-48f5c4eec6c85b5c91e8d45921afe8d62410239b.zip
cpython-48f5c4eec6c85b5c91e8d45921afe8d62410239b.tar.gz
cpython-48f5c4eec6c85b5c91e8d45921afe8d62410239b.tar.bz2
Implement test for sys.path_importer_cache having None for
importlib.machinery.PathFinder.
Diffstat (limited to 'Lib/importlib/test')
-rw-r--r--Lib/importlib/test/import_/test_path.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/Lib/importlib/test/import_/test_path.py b/Lib/importlib/test/import_/test_path.py
index 3eb22c9..70dae2f 100644
--- a/Lib/importlib/test/import_/test_path.py
+++ b/Lib/importlib/test/import_/test_path.py
@@ -3,6 +3,7 @@ from .. import util
from . import util as import_util
from contextlib import nested
from imp import new_module
+import os
import sys
from types import MethodType
import unittest
@@ -191,8 +192,19 @@ class FinderTests(unittest.TestCase):
def test_path_importer_cache_has_None(self):
# Test that the default hook is used when sys.path_importer_cache
# contains None for a path.
- # TODO(brett.cannon) implement
- pass
+ module = '<test module>'
+ importer = util.mock_modules(module)
+ path = '<test path>'
+ # XXX Not blackbox.
+ original_hook = machinery.PathFinder._default_hook
+ mock_hook = import_util.mock_path_hook(path, importer=importer)
+ machinery.PathFinder._default_hook = staticmethod(mock_hook)
+ try:
+ with util.import_state(path_importer_cache={path: None}):
+ loader = machinery.PathFinder.find_module(module, path=[path])
+ self.assert_(loader is importer)
+ finally:
+ machinery.PathFinder._default_hook = original_hook
def test_path_hooks(self):
# Test that sys.path_hooks is used.