Issue #22834: Fix a failing test under Solaris due to the platform not

allowing the deletion of the cwd.

Thanks to Martin Panter for the initial fix.
This commit is contained in:
Brett Cannon 2015-02-20 09:48:18 -05:00
parent abbf0f40bb
commit 16cd19c8a2
1 changed files with 8 additions and 2 deletions

View File

@ -163,8 +163,14 @@ class FinderTests:
def test_deleted_cwd(self): def test_deleted_cwd(self):
# Issue #22834 # Issue #22834
self.addCleanup(os.chdir, os.getcwd()) self.addCleanup(os.chdir, os.getcwd())
with tempfile.TemporaryDirectory() as path: try:
os.chdir(path) with tempfile.TemporaryDirectory() as path:
os.chdir(path)
except OSError as exc:
if exc.errno == 22:
# issue #22834
self.skipTest("platform does not allow the deletion of the cwd")
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'))