gh-100131: Add optional delete parameter to tempfile.TemporaryDirectory() (#100132)

Add optional delete parameter to tempfile.TemporaryDirectory().

Co-authored-by: Gregory P. Smith <greg@krypto.org>
This commit is contained in:
JakobDev 2023-03-24 22:52:06 +01:00 committed by GitHub
parent ded9a7fc19
commit 64cb1a4f0f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 8 deletions

View file

@ -12,6 +12,7 @@ import stat
import types
import weakref
import gc
import shutil
from unittest import mock
import unittest
@ -1837,6 +1838,11 @@ class TestTemporaryDirectory(BaseTestCase):
d.cleanup()
self.assertFalse(os.path.exists(d.name))
def test_delete_false(self):
with tempfile.TemporaryDirectory(delete=False) as working_dir:
pass
self.assertTrue(os.path.exists(working_dir))
shutil.rmtree(working_dir)
if __name__ == "__main__":
unittest.main()