diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2012-03-02 01:24:13 (GMT) |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2012-03-02 01:24:13 (GMT) |
commit | 2f24d98df08fbed8e7c82a3de1843ef27b779739 (patch) | |
tree | 038b097ad8c79e0a8f558437990fedd576f39377 /Lib/test/test_mailbox.py | |
parent | be52d507d2ada0d13ad9e482f00908173d8900f0 (diff) | |
parent | f959618142888fab373c43edd35f20506a9740dc (diff) | |
download | cpython-2f24d98df08fbed8e7c82a3de1843ef27b779739.zip cpython-2f24d98df08fbed8e7c82a3de1843ef27b779739.tar.gz cpython-2f24d98df08fbed8e7c82a3de1843ef27b779739.tar.bz2 |
Closes #14158: merged test file resilience fix from 3.2.
Diffstat (limited to 'Lib/test/test_mailbox.py')
-rw-r--r-- | Lib/test/test_mailbox.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Lib/test/test_mailbox.py b/Lib/test/test_mailbox.py index 4bb05a4..212ceb9 100644 --- a/Lib/test/test_mailbox.py +++ b/Lib/test/test_mailbox.py @@ -7,6 +7,7 @@ import email import email.message import re import io +import shutil import tempfile from test import support import unittest @@ -38,12 +39,7 @@ class TestBase(unittest.TestCase): def _delete_recursively(self, target): # Delete a file or delete a directory recursively if os.path.isdir(target): - for path, dirs, files in os.walk(target, topdown=False): - for name in files: - os.remove(os.path.join(path, name)) - for name in dirs: - os.rmdir(os.path.join(path, name)) - os.rmdir(target) + shutil.rmtree(target) elif os.path.exists(target): os.remove(target) @@ -2028,6 +2024,10 @@ class MaildirTestCase(unittest.TestCase): def setUp(self): # create a new maildir mailbox to work with: self._dir = support.TESTFN + if os.path.isdir(self._dir): + shutil.rmtree(self._dir) + elif os.path.isfile(self._dir): + os.unlink(self._dir) os.mkdir(self._dir) os.mkdir(os.path.join(self._dir, "cur")) os.mkdir(os.path.join(self._dir, "tmp")) |