Skip to content

Commit 7fb7bd9

Browse files
author
bwilson
committed
Add a hook to allow overriding the remote module that's executed by execnet
1 parent 1efec5a commit 7fb7bd9

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

xdist/newhooks.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ def pytest_xdist_rsyncfinish(source, gateways):
3030
""" called after rsyncing a directory to remote gateways takes place. """
3131

3232

33+
@pytest.mark.firstresult
34+
def pytest_xdist_getremotemodule():
35+
""" called when creating remote node"""
36+
37+
3338
def pytest_configure_node(node):
3439
""" configure node information before it gets instantiated. """
3540

xdist/workermanage.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,13 @@ def make_reltoroot(roots, args):
203203
class WorkerController(object):
204204
ENDMARK = -1
205205

206+
class RemoteHook:
207+
@pytest.mark.trylast
208+
def pytest_xdist_getremotemodule(self):
209+
return xdist.remote
210+
206211
def __init__(self, nodemanager, gateway, config, putevent):
212+
config.pluginmanager.register(self.RemoteHook())
207213
self.nodemanager = nodemanager
208214
self.putevent = putevent
209215
self.gateway = gateway
@@ -242,7 +248,8 @@ def setup(self):
242248
basetemp = self.config._tmpdirhandler.getbasetemp()
243249
option_dict["basetemp"] = str(basetemp.join(name))
244250
self.config.hook.pytest_configure_node(node=self)
245-
self.channel = self.gateway.remote_exec(xdist.remote)
251+
remote_module = self.config.hook.pytest_xdist_getremotemodule()
252+
self.channel = self.gateway.remote_exec(remote_module)
246253
self.channel.send((self.workerinput, args, option_dict))
247254
if self.putevent:
248255
self.channel.setcallback(self.process_from_remote, endmarker=self.ENDMARK)

0 commit comments

Comments
 (0)