mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
Issue #25595: Fixed test_deleted_cwd in test_importlib on AIX.
This commit is contained in:
commit
3dc56a6cec
1 changed files with 14 additions and 8 deletions
|
@ -3,7 +3,6 @@ from .. import util
|
||||||
importlib = util.import_importlib('importlib')
|
importlib = util.import_importlib('importlib')
|
||||||
machinery = util.import_importlib('importlib.machinery')
|
machinery = util.import_importlib('importlib.machinery')
|
||||||
|
|
||||||
import errno
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
|
@ -160,17 +159,24 @@ class FinderTests:
|
||||||
got = self.machinery.PathFinder.find_spec('whatever', [path])
|
got = self.machinery.PathFinder.find_spec('whatever', [path])
|
||||||
self.assertEqual(got, success_finder.spec)
|
self.assertEqual(got, success_finder.spec)
|
||||||
|
|
||||||
@unittest.skipIf(sys.platform == 'win32', "cwd can't not exist on Windows")
|
|
||||||
def test_deleted_cwd(self):
|
def test_deleted_cwd(self):
|
||||||
# Issue #22834
|
# Issue #22834
|
||||||
self.addCleanup(os.chdir, os.getcwd())
|
old_dir = os.getcwd()
|
||||||
|
self.addCleanup(os.chdir, old_dir)
|
||||||
|
new_dir = tempfile.mkdtemp()
|
||||||
try:
|
try:
|
||||||
with tempfile.TemporaryDirectory() as path:
|
os.chdir(new_dir)
|
||||||
os.chdir(path)
|
try:
|
||||||
except OSError as exc:
|
os.rmdir(new_dir)
|
||||||
if exc.errno == errno.EINVAL:
|
except OSError:
|
||||||
self.skipTest("platform does not allow the deletion of the cwd")
|
# EINVAL on Solaris, EBUSY on AIX, ENOTEMPTY on Windows
|
||||||
|
self.skipTest("platform does not allow "
|
||||||
|
"the deletion of the cwd")
|
||||||
|
except:
|
||||||
|
os.chdir(old_dir)
|
||||||
|
os.rmdir(new_dir)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
with util.import_state(path=['']):
|
with util.import_state(path=['']):
|
||||||
# Do not want FileNotFoundError raised.
|
# Do not want FileNotFoundError raised.
|
||||||
self.assertIsNone(self.machinery.PathFinder.find_spec('whatever'))
|
self.assertIsNone(self.machinery.PathFinder.find_spec('whatever'))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue