fix sys.path for local workers Fixes #421

This commit is contained in:
Thomas Grainger
2021-06-03 21:07:01 +01:00
parent 7f2426b11d
commit 56e631b4bb
4 changed files with 24 additions and 3 deletions

View File

@@ -9,6 +9,7 @@ import pytest
import execnet
import xdist.remote
from xdist.plugin import _sys_path
def parse_spec_config(config):
@@ -261,7 +262,8 @@ class WorkerController:
remote_module = self.config.hook.pytest_xdist_getremotemodule()
self.channel = self.gateway.remote_exec(remote_module)
# change sys.path only for remote workers
change_sys_path = not self.gateway.spec.popen
# restore sys.path from a frozen copy for local workers
change_sys_path = _sys_path if self.gateway.spec.popen else None
self.channel.send((self.workerinput, args, option_dict, change_sys_path))
if self.putevent: