mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Issue #22834: Have import suppress FileNotFoundError when the current
working directory no longer exists. Thanks to Martin Panter for the bug report.
This commit is contained in:
parent
8314690a26
commit
b6e2556d8f
7 changed files with 1043 additions and 1001 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue