diff options
author | R David Murray <rdmurray@bitdance.com> | 2013-02-11 15:14:24 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2013-02-11 15:14:24 (GMT) |
commit | f1d3473a2bcc52745bab2953fb91a26676629de7 (patch) | |
tree | 6e49a1e45ac76e5b1461ec807427f3dd8fbb6d75 | |
parent | c36bf9918929ae37db1fea149ff9d9d408e62943 (diff) | |
download | cpython-f1d3473a2bcc52745bab2953fb91a26676629de7.zip cpython-f1d3473a2bcc52745bab2953fb91a26676629de7.tar.gz cpython-f1d3473a2bcc52745bab2953fb91a26676629de7.tar.bz2 |
#17064: fix sporadic permission errors in test_mailbox on windows.
Backported from patch by Jeremy Kloth.
-rw-r--r-- | Lib/test/test_mailbox.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/Lib/test/test_mailbox.py b/Lib/test/test_mailbox.py index 01c4373..5e8e3c1 100644 --- a/Lib/test/test_mailbox.py +++ b/Lib/test/test_mailbox.py @@ -40,9 +40,9 @@ class TestBase: def _delete_recursively(self, target): # Delete a file or delete a directory recursively if os.path.isdir(target): - shutil.rmtree(target) + test_support.rmtree(target) elif os.path.exists(target): - os.remove(target) + test_support.unlink(target) class TestMailbox(TestBase): @@ -1927,6 +1927,10 @@ class MaildirTestCase(unittest.TestCase): def setUp(self): # create a new maildir mailbox to work with: self._dir = test_support.TESTFN + if os.path.isdir(self._dir): + test_support.rmtree(self._dir) + if os.path.isfile(self._dir): + test_support.unlink(self._dir) os.mkdir(self._dir) os.mkdir(os.path.join(self._dir, "cur")) os.mkdir(os.path.join(self._dir, "tmp")) @@ -1936,10 +1940,10 @@ class MaildirTestCase(unittest.TestCase): def tearDown(self): map(os.unlink, self._msgfiles) - os.rmdir(os.path.join(self._dir, "cur")) - os.rmdir(os.path.join(self._dir, "tmp")) - os.rmdir(os.path.join(self._dir, "new")) - os.rmdir(self._dir) + test_support.rmdir(os.path.join(self._dir, "cur")) + test_support.rmdir(os.path.join(self._dir, "tmp")) + test_support.rmdir(os.path.join(self._dir, "new")) + test_support.rmdir(self._dir) def createMessage(self, dir, mbox=False): t = int(time.time() % 1000000) |