mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
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:
parent
ded9a7fc19
commit
64cb1a4f0f
4 changed files with 35 additions and 8 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue