summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_tempfile.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2023-12-07 17:21:36 (GMT)
committerGitHub <noreply@github.com>2023-12-07 17:21:36 (GMT)
commitb2923a61a10dc2717f4662b590cc9f6d181c6983 (patch)
tree5524d311fd78aea3cccb99bc15908b1a8b20b5a8 /Lib/test/test_tempfile.py
parentba18893555bbf69b1da262aaf85d65e4b67e8955 (diff)
downloadcpython-b2923a61a10dc2717f4662b590cc9f6d181c6983.zip
cpython-b2923a61a10dc2717f4662b590cc9f6d181c6983.tar.gz
cpython-b2923a61a10dc2717f4662b590cc9f6d181c6983.tar.bz2
gh-79325: Fix recursion error in TemporaryDirectory cleanup on Windows (GH-112762)
Diffstat (limited to 'Lib/test/test_tempfile.py')
-rw-r--r--Lib/test/test_tempfile.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_tempfile.py b/Lib/test/test_tempfile.py
index 2729bec..b64b6a4 100644
--- a/Lib/test/test_tempfile.py
+++ b/Lib/test/test_tempfile.py
@@ -1651,6 +1651,17 @@ class TestTemporaryDirectory(BaseTestCase):
with self.assertRaises(PermissionError):
temp_dir.cleanup()
+ @unittest.skipUnless(os.name == "nt", "Only on Windows.")
+ def test_cleanup_with_used_directory(self):
+ with tempfile.TemporaryDirectory() as working_dir:
+ temp_dir = self.do_create(dir=working_dir)
+ subdir = os.path.join(temp_dir.name, "subdir")
+ os.mkdir(subdir)
+ with os_helper.change_cwd(subdir):
+ # Previously raised RecursionError on some OSes
+ # (e.g. Windows). See bpo-35144.
+ with self.assertRaises(PermissionError):
+ temp_dir.cleanup()
@os_helper.skip_unless_symlink
def test_cleanup_with_symlink_to_a_directory(self):