From b5b580fe8a34c530aad1c897b8ad4718f8f7db86 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 10 Jan 2010 10:41:10 -0500 Subject: Avoid random file deletion errors on Windows. --- test/test_farm.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'test/test_farm.py') diff --git a/test/test_farm.py b/test/test_farm.py index 630f1011..6adfe6ad 100644 --- a/test/test_farm.py +++ b/test/test_farm.py @@ -295,7 +295,11 @@ class FarmTestCase(object): def clean(self, cleandir): """Clean `cleandir` by removing it and all its children completely.""" if os.path.exists(cleandir): - shutil.rmtree(cleandir) + # rmtree gives mysterious failures on Win7, so use an onerror + # function that simply retries the operation. Why that helps, I + # have no idea. + shutil.rmtree(cleandir, onerror=lambda fn, path, exc: fn(path)) + def main(): # pragma: no cover """Command-line access to test_farm. -- cgit v1.2.1