[Python-checkins] cpython (merge 3.5 -> default): Issue #25595: Fixed test_deleted_cwd in test_importlib on AIX.
serhiy.storchaka
python-checkins at python.org
Wed Nov 11 01:27:32 EST 2015
https://hg.python.org/cpython/rev/3f392050d519
changeset: 99055:3f392050d519
parent: 99052:d1c11a78b43a
parent: 99054:d4dc36586f24
user: Serhiy Storchaka <storchaka at gmail.com>
date: Wed Nov 11 08:27:13 2015 +0200
summary:
Issue #25595: Fixed test_deleted_cwd in test_importlib on AIX.
files:
Lib/test/test_importlib/import_/test_path.py | 22 ++++++---
1 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/Lib/test/test_importlib/import_/test_path.py b/Lib/test/test_importlib/import_/test_path.py
--- a/Lib/test/test_importlib/import_/test_path.py
+++ b/Lib/test/test_importlib/import_/test_path.py
@@ -3,7 +3,6 @@
importlib = util.import_importlib('importlib')
machinery = util.import_importlib('importlib.machinery')
-import errno
import os
import sys
import tempfile
@@ -160,17 +159,24 @@
got = self.machinery.PathFinder.find_spec('whatever', [path])
self.assertEqual(got, success_finder.spec)
- @unittest.skipIf(sys.platform == 'win32', "cwd can't not exist on Windows")
def test_deleted_cwd(self):
# Issue #22834
- self.addCleanup(os.chdir, os.getcwd())
+ old_dir = os.getcwd()
+ self.addCleanup(os.chdir, old_dir)
+ new_dir = tempfile.mkdtemp()
try:
- with tempfile.TemporaryDirectory() as path:
- os.chdir(path)
- except OSError as exc:
- if exc.errno == errno.EINVAL:
- self.skipTest("platform does not allow the deletion of the cwd")
+ os.chdir(new_dir)
+ try:
+ os.rmdir(new_dir)
+ except OSError:
+ # 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
+
with util.import_state(path=['']):
# Do not want FileNotFoundError raised.
self.assertIsNone(self.machinery.PathFinder.find_spec('whatever'))
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list