diff options
-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): |