summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_importlib
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2014-11-21 17:19:28 (GMT)
committerBrett Cannon <brett@python.org>2014-11-21 17:19:28 (GMT)
commitb6e2556d8fbd172181aac09b7536563635af63a9 (patch)
tree07dcdf2a20ae9d8c82ead835491ab6ed7eccfaaa /Lib/test/test_importlib
parent8314690a26501b3693f9a1f18c85f240a6c973bb (diff)
downloadcpython-b6e2556d8fbd172181aac09b7536563635af63a9.zip
cpython-b6e2556d8fbd172181aac09b7536563635af63a9.tar.gz
cpython-b6e2556d8fbd172181aac09b7536563635af63a9.tar.bz2
Issue #22834: Have import suppress FileNotFoundError when the current
working directory no longer exists. Thanks to Martin Panter for the bug report.
Diffstat (limited to 'Lib/test/test_importlib')
-rw-r--r--Lib/test/test_importlib/import_/test_path.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_importlib/import_/test_path.py b/Lib/test/test_importlib/import_/test_path.py
index e86c655..d5442c3 100644
--- a/Lib/test/test_importlib/import_/test_path.py
+++ b/Lib/test/test_importlib/import_/test_path.py
@@ -5,6 +5,7 @@ machinery = util.import_importlib('importlib.machinery')
import os
import sys
+import tempfile
from types import ModuleType
import unittest
import warnings
@@ -158,6 +159,17 @@ class FinderTests:
got = self.machinery.PathFinder.find_spec('whatever', [path])
self.assertEqual(got, success_finder.spec)
+ def test_deleted_cwd(self):
+ # Issue #22834
+ self.addCleanup(os.chdir, os.getcwd())
+ with tempfile.TemporaryDirectory() as path:
+ os.chdir(path)
+ with util.import_state(path=['']):
+ # Do not want FileNotFoundError raised.
+ self.assertIsNone(self.machinery.PathFinder.find_spec('whatever'))
+
+
+
(Frozen_FinderTests,
Source_FinderTests