diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2019-11-26 06:26:12 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2019-11-26 15:45:36 -0500 |
commit | 34e00adac3a829160d6fe50a6ec7f8e632ef24a7 (patch) | |
tree | 2b12ed51635492adfc5a8a6426477ff834f9a3f1 /tests/test_process.py | |
parent | 8c82b63807a1f0c66d6192ada92ee6808df3534f (diff) | |
download | python-coveragepy-git-34e00adac3a829160d6fe50a6ec7f8e632ef24a7.tar.gz |
Run windows tests in parallel
... and fix the cleanup that prevented it previously by retrying until
the cleanup succeeds.
Diffstat (limited to 'tests/test_process.py')
-rw-r--r-- | tests/test_process.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/test_process.py b/tests/test_process.py index e9e19e8a..d3f7d56f 100644 --- a/tests/test_process.py +++ b/tests/test_process.py @@ -11,6 +11,7 @@ import os.path import re import sys import textwrap +import time from xml.etree import ElementTree import pytest @@ -1369,6 +1370,20 @@ WORKER = os.environ.get('PYTEST_XDIST_WORKER', '') PTH_DIR = find_writable_pth_directory() +def persistent_remove(path): + """Remove a file, and retry for a while if you can't.""" + tries = 100 + while tries: # pragma: part covered + try: + os.remove(path) + except OSError: + tries -= 1 + time.sleep(.05) + else: + return + raise Exception("Sorry, couldn't remove {!r}".format(path)) # pragma: cant happen + + class ProcessCoverageMixin(object): """Set up a .pth file to coverage-measure all sub-processes.""" @@ -1383,7 +1398,7 @@ class ProcessCoverageMixin(object): pth.write(pth_contents) self.pth_path = pth_path - self.addCleanup(os.remove, self.pth_path) + self.addCleanup(persistent_remove, self.pth_path) class ProcessStartupTest(ProcessCoverageMixin, CoverageTest): |