summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSviatoslav Sydorenko <wk@sydorenko.org.ua>2021-01-01 02:24:08 +0100
committerSviatoslav Sydorenko <wk@sydorenko.org.ua>2021-01-18 00:47:04 +0100
commitc9188cbf991dbaac6d94b0dd57d3132760fc9e89 (patch)
tree9685af0bcb5dd35406adc23522e8cb1c163fbeff
parentd3885f25e37b28fe5a50274a5db9819d5e2ce042 (diff)
downloadpython-setuptools-git-c9188cbf991dbaac6d94b0dd57d3132760fc9e89.tar.gz
Sanitize CWD out of sys.path in xdist mode
-rw-r--r--setuptools/tests/test_build_meta.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/setuptools/tests/test_build_meta.py b/setuptools/tests/test_build_meta.py
index 6d3a997e..b0455a62 100644
--- a/setuptools/tests/test_build_meta.py
+++ b/setuptools/tests/test_build_meta.py
@@ -1,8 +1,10 @@
import os
import shutil
+import sys
import tarfile
import importlib
from concurrent import futures
+from contextlib import suppress
import pytest
@@ -44,6 +46,15 @@ class BuildBackendCaller(BuildBackendBase):
def __call__(self, name, *args, **kw):
"""Handles aribrary function invocations on the build backend."""
+ with suppress(ValueError):
+ # NOTE: pytest-xdist tends to inject '' into `sys.path` which
+ # NOTE: may break certain isolation expectations. To address
+ # NOTE: this, we remove this entry from there so the import
+ # NOTE: machinery behaves the same as in the default
+ # NOTE: sequential mode.
+ # Ref: https://github.com/pytest-dev/pytest-xdist/issues/376
+ sys.path.remove('')
+
os.chdir(self.cwd)
os.environ.update(self.env)
mod = importlib.import_module(self.backend_name)