diff -r 1e77ce67699e Lib/test/test_importlib/import_/test_path.py --- a/Lib/test/test_importlib/import_/test_path.py Tue Nov 10 00:31:28 2015 +0200 +++ b/Lib/test/test_importlib/import_/test_path.py Tue Nov 10 12:54:03 2015 +0200 @@ -164,13 +164,16 @@ class FinderTests: def test_deleted_cwd(self): # Issue #22834 self.addCleanup(os.chdir, os.getcwd()) + path = 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") - raise + os.chdir(path) + finally: + try: + os.rmdir(path) + except OSError as exc: + if exc.errno in (errno.EINVAL, errno.EBUSY): + self.skipTest("platform does not allow the deletion of the cwd") + raise with util.import_state(path=['']): # Do not want FileNotFoundError raised. self.assertIsNone(self.machinery.PathFinder.find_spec('whatever'))