Commit c9188cbf authored by Sviatoslav Sydorenko's avatar Sviatoslav Sydorenko

Sanitize CWD out of sys.path in xdist mode

parent d3885f25
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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment