diff --git a/Lib/test/test_importlib/import_/test_path.py b/Lib/test/test_importlib/import_/test_path.py index 9a3c4fe877f..f257f117b47 100644 --- a/Lib/test/test_importlib/import_/test_path.py +++ b/Lib/test/test_importlib/import_/test_path.py @@ -163,8 +163,14 @@ def find_spec(self, fullname, target=None): def test_deleted_cwd(self): # Issue #22834 self.addCleanup(os.chdir, os.getcwd()) - with tempfile.TemporaryDirectory() as path: - os.chdir(path) + try: + 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=['']): # Do not want FileNotFoundError raised. self.assertIsNone(self.machinery.PathFinder.find_spec('whatever'))