summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2010-03-20 12:28:08 -0400
committerNed Batchelder <ned@nedbatchelder.com>2010-03-20 12:28:08 -0400
commitf3b018380b32e1e75a00ac5b1b730c0c67ab060c (patch)
tree65c406348278a22b47f5ada18691c9723fd5fc1b
parent119a0d4032915b5bbf2b40c1338e53ba5ca096d2 (diff)
downloadpython-coveragepy-f3b018380b32e1e75a00ac5b1b730c0c67ab060c.tar.gz
Maybe we're done with the scourge of failed tree deletes on Windows?
-rw-r--r--test/test_farm.py26
1 files changed, 12 insertions, 14 deletions
diff --git a/test/test_farm.py b/test/test_farm.py
index 405c68d..08e51cd 100644
--- a/test/test_farm.py
+++ b/test/test_farm.py
@@ -295,20 +295,18 @@ class FarmTestCase(object):
def clean(self, cleandir):
"""Clean `cleandir` by removing it and all its children completely."""
if os.path.exists(cleandir):
- # rmtree gives mysterious failures on Win7, so use an onerror
- # function that tries to help diagnose the problem. Somehow, just
- # having a function that prints and raises keeps the error from
- # happening??
- shutil.rmtree(cleandir, onerror=self.rmtree_err)
-
- def rmtree_err(self, fn, path, exc):
- """A stupid error handler that prints and raises.
-
- Somehow, this fixes the problem it was meant to diagnose.
-
- """
- print("Couldn't %r on %r due to %s" % (fn, path, exc))
- raise exc
+ # rmtree gives mysterious failures on Win7, so retry a few times.
+ tries = 3
+ while tries:
+ try:
+ shutil.rmtree(cleandir)
+ except OSError:
+ if tries == 1:
+ raise
+ else:
+ tries -= 1
+ continue
+ break
def main(): # pragma: no cover