summaryrefslogtreecommitdiffstats
path: root/Lib/importlib/test
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2012-02-08 23:52:56 (GMT)
committerBrett Cannon <brett@python.org>2012-02-08 23:52:56 (GMT)
commitb4e63b3177f50d519aeac2f59d38af4503b82d62 (patch)
treeb94d1946b9b4889ed9d679667afe0a0bc517e819 /Lib/importlib/test
parent354c26ecd6d1f6341bb1f65ea099d6952a29abd8 (diff)
downloadcpython-b4e63b3177f50d519aeac2f59d38af4503b82d62.zip
cpython-b4e63b3177f50d519aeac2f59d38af4503b82d62.tar.gz
cpython-b4e63b3177f50d519aeac2f59d38af4503b82d62.tar.bz2
Use the cwd when the empty string is found in sys.path. This leads to
__file__ being an absolute path when the module is found in the current directory.
Diffstat (limited to 'Lib/importlib/test')
-rw-r--r--Lib/importlib/test/import_/test_path.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/importlib/test/import_/test_path.py b/Lib/importlib/test/import_/test_path.py
index 2faa231..b28f25d 100644
--- a/Lib/importlib/test/import_/test_path.py
+++ b/Lib/importlib/test/import_/test_path.py
@@ -73,6 +73,16 @@ class FinderTests(unittest.TestCase):
loader = machinery.PathFinder.find_module(module)
self.assertTrue(loader is importer)
+ def test_path_importer_cache_empty_string(self):
+ # The empty string should create a finder using the cwd.
+ path = ''
+ module = '<test module>'
+ importer = util.mock_modules(module)
+ hook = import_util.mock_path_hook(os.getcwd(), importer=importer)
+ with util.import_state(path=[path], path_hooks=[hook]):
+ loader = machinery.PathFinder.find_module(module)
+ self.assertIs(loader, importer)
+ self.assertIn('', sys.path_importer_cache)
class DefaultPathFinderTests(unittest.TestCase):