Issue #15817: Bugfix: remove temporary directories test_shutil was leaving

behind.
This commit is contained in:
Larry Hastings 2012-06-25 23:50:01 -07:00
parent 93e3d3ac09
commit 5b2f9c0aff
2 changed files with 6 additions and 0 deletions

View File

@ -1174,6 +1174,7 @@ class TestShutil(unittest.TestCase):
# copytree returns its destination path. # copytree returns its destination path.
src_dir = self.mkdtemp() src_dir = self.mkdtemp()
dst_dir = src_dir + "dest" dst_dir = src_dir + "dest"
self.addCleanup(shutil.rmtree, dst_dir, True)
src = os.path.join(src_dir, 'foo') src = os.path.join(src_dir, 'foo')
write_file(src, 'foo') write_file(src, 'foo')
rv = shutil.copytree(src_dir, dst_dir) rv = shutil.copytree(src_dir, dst_dir)
@ -1184,6 +1185,7 @@ class TestWhich(unittest.TestCase):
def setUp(self): def setUp(self):
self.temp_dir = tempfile.mkdtemp() self.temp_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, self.temp_dir, True)
# Give the temp_file an ".exe" suffix for all. # Give the temp_file an ".exe" suffix for all.
# It's needed on Windows and not harmful on other platforms. # It's needed on Windows and not harmful on other platforms.
self.temp_file = tempfile.NamedTemporaryFile(dir=self.temp_dir, self.temp_file = tempfile.NamedTemporaryFile(dir=self.temp_dir,
@ -1506,6 +1508,7 @@ class TestCopyFile(unittest.TestCase):
# but a different case. # but a different case.
self.src_dir = tempfile.mkdtemp() self.src_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, self.src_dir, True)
dst_dir = os.path.join( dst_dir = os.path.join(
os.path.dirname(self.src_dir), os.path.dirname(self.src_dir),
os.path.basename(self.src_dir).upper()) os.path.basename(self.src_dir).upper())

View File

@ -58,6 +58,9 @@ Core and Builtins
Library Library
------- -------
- Issue #15817: Bugfix: remove temporary directories test_shutil was leaving
behind.
- Issue #15177: Added dir_fd parameter to os.fwalk(). - Issue #15177: Added dir_fd parameter to os.fwalk().
- Issue #15176: Clarified behavior, documentation, and implementation - Issue #15176: Clarified behavior, documentation, and implementation