diff options
| author | Ned Batchelder <ned@nedbatchelder.com> | 2010-03-06 11:46:31 -0500 |
|---|---|---|
| committer | Ned Batchelder <ned@nedbatchelder.com> | 2010-03-06 11:46:31 -0500 |
| commit | 7c404dae7e4e45bdaa3c93ba459945f8ae2b7654 (patch) | |
| tree | e61ea0859453d26f53e3161be94d8ba4aa0c6364 | |
| parent | 187c90b1d900be6105f3338f92097c93c4a498b4 (diff) | |
| download | python-coveragepy-7c404dae7e4e45bdaa3c93ba459945f8ae2b7654.tar.gz | |
The niggling errors cleaning directories on Windows 7 seem to be fixed by this function which was only meant to help diagnose the problem. A heisenbug!
| -rw-r--r-- | test/test_farm.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/test/test_farm.py b/test/test_farm.py index 6adfe6a..405c68d 100644 --- a/test/test_farm.py +++ b/test/test_farm.py @@ -296,9 +296,19 @@ class FarmTestCase(object): """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 simply retries the operation. Why that helps, I - # have no idea. - shutil.rmtree(cleandir, onerror=lambda fn, path, exc: fn(path)) + # 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 def main(): # pragma: no cover |
