It seems better to cache the finder for the cwd under its full path
insetad of '' in case the cwd changes. Otherwise FileFinder needs to
dynamically change itself based on whether it is given '' instead of
caching a finder for every change to the cwd.
the default hook, for which ImportError is raised.
"""
+ if path == '':
+ path = _os.getcwd()
try:
finder = sys.path_importer_cache[path]
except KeyError:
- finder = cls._path_hooks(path if path != '' else _os.getcwd())
+ finder = cls._path_hooks(path)
sys.path_importer_cache[path] = finder
else:
if finder is None and default:
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)
+ self.assertIn(os.getcwd(), sys.path_importer_cache)
class DefaultPathFinderTests(unittest.TestCase):