3
changelog/376.feature.rst
Normal file
3
changelog/376.feature.rst
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
The current directory is no longer added ``sys.path`` for local workers, only for remote connections.
|
||||||
|
|
||||||
|
This behavior is surprising because it makes xdist runs and non-xdist runs to potentially behave differently.
|
||||||
@@ -251,17 +251,20 @@ def remote_initconfig(option_dict, args):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__channelexec__":
|
if __name__ == "__channelexec__":
|
||||||
|
import py
|
||||||
|
|
||||||
channel = channel # noqa
|
channel = channel # noqa
|
||||||
workerinput, args, option_dict = channel.receive()
|
workerinput, args, option_dict, change_sys_path = channel.receive()
|
||||||
importpath = os.getcwd()
|
|
||||||
sys.path.insert(0, importpath) # XXX only for remote situations
|
if change_sys_path:
|
||||||
os.environ["PYTHONPATH"] = (
|
importpath = os.getcwd()
|
||||||
importpath + os.pathsep + os.environ.get("PYTHONPATH", "")
|
sys.path.insert(0, importpath)
|
||||||
)
|
os.environ["PYTHONPATH"] = (
|
||||||
|
importpath + os.pathsep + os.environ.get("PYTHONPATH", "")
|
||||||
|
)
|
||||||
|
|
||||||
os.environ["PYTEST_XDIST_WORKER"] = workerinput["workerid"]
|
os.environ["PYTEST_XDIST_WORKER"] = workerinput["workerid"]
|
||||||
os.environ["PYTEST_XDIST_WORKER_COUNT"] = str(workerinput["workercount"])
|
os.environ["PYTEST_XDIST_WORKER_COUNT"] = str(workerinput["workercount"])
|
||||||
# os.environ['PYTHONPATH'] = importpath
|
|
||||||
import py
|
|
||||||
|
|
||||||
config = remote_initconfig(option_dict, args)
|
config = remote_initconfig(option_dict, args)
|
||||||
config._parser.prog = os.path.basename(workerinput["mainargv"][0])
|
config._parser.prog = os.path.basename(workerinput["mainargv"][0])
|
||||||
|
|||||||
@@ -245,7 +245,9 @@ class WorkerController(object):
|
|||||||
option_dict["basetemp"] = str(basetemp.join(name))
|
option_dict["basetemp"] = str(basetemp.join(name))
|
||||||
self.config.hook.pytest_configure_node(node=self)
|
self.config.hook.pytest_configure_node(node=self)
|
||||||
self.channel = self.gateway.remote_exec(xdist.remote)
|
self.channel = self.gateway.remote_exec(xdist.remote)
|
||||||
self.channel.send((self.workerinput, args, option_dict))
|
# change sys.path only for remote workers
|
||||||
|
change_sys_path = not self.gateway.spec.popen
|
||||||
|
self.channel.send((self.workerinput, args, option_dict, change_sys_path))
|
||||||
if self.putevent:
|
if self.putevent:
|
||||||
self.channel.setcallback(self.process_from_remote, endmarker=self.ENDMARK)
|
self.channel.setcallback(self.process_from_remote, endmarker=self.ENDMARK)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user