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 | |
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.
-rw-r--r-- | appveyor.yml | 4 | ||||
-rw-r--r-- | tests/test_process.py | 17 |
2 files changed, 17 insertions, 4 deletions
diff --git a/appveyor.yml b/appveyor.yml index e11f36b6..0fb8903d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -12,9 +12,7 @@ environment: CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\ci\\run_with_env.cmd" - # Parallel pytest gets tangled up with tests that try to create and destroy - # .pth files in the shared virtualenv. Disable parallel tests. - PYTEST_ADDOPTS: "-n 0" + PYTEST_ADDOPTS: "-n auto" # Note: There is logic to install Python version $PYTHON_VERSION if the # $PYTHON directory doesn't exist. $PYTHON_VERSION is visible in the job 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): |