mirror of https://github.com/python/cpython
Make test_shutil clean up after itself
This commit is contained in:
parent
a6714b2887
commit
4ac6b93c00
|
@ -118,7 +118,7 @@ class TestShutil(unittest.TestCase):
|
|||
if os.path.exists(path):
|
||||
os.remove(path)
|
||||
for path in (src_dir,
|
||||
os.path.abspath(os.path.join(dst_dir, os.path.pardir))
|
||||
os.path.dirname(dst_dir)
|
||||
):
|
||||
if os.path.exists(path):
|
||||
shutil.rmtree(path)
|
||||
|
@ -140,6 +140,7 @@ class TestShutil(unittest.TestCase):
|
|||
join = os.path.join
|
||||
exists = os.path.exists
|
||||
src_dir = tempfile.mkdtemp()
|
||||
try:
|
||||
dst_dir = join(tempfile.mkdtemp(), 'destination')
|
||||
write_data(join(src_dir, 'test.txt'), '123')
|
||||
write_data(join(src_dir, 'test.tmp'), '123')
|
||||
|
@ -199,6 +200,9 @@ class TestShutil(unittest.TestCase):
|
|||
finally:
|
||||
if os.path.exists(dst_dir):
|
||||
shutil.rmtree(dst_dir)
|
||||
finally:
|
||||
shutil.rmtree(src_dir)
|
||||
shutil.rmtree(os.path.dirname(dst_dir))
|
||||
|
||||
if hasattr(os, "symlink"):
|
||||
def test_dont_copy_file_onto_link_to_itself(self):
|
||||
|
|
Loading…
Reference in New Issue