From c8da61a7d3a7d809343aa017c582ab062d795da3 Mon Sep 17 00:00:00 2001 From: hpk Date: Fri, 20 Mar 2009 18:14:45 +0100 Subject: [PATCH] [svn r63149] always have a default chdir --HG-- branch : trunk --- py/execnet/gwmanage.py | 10 ++++++++-- py/execnet/testing/test_gwmanage.py | 11 +++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/py/execnet/gwmanage.py b/py/execnet/gwmanage.py index f9a52e4b5..1ef613e54 100644 --- a/py/execnet/gwmanage.py +++ b/py/execnet/gwmanage.py @@ -12,9 +12,15 @@ NO_ENDMARKER_WANTED = object() class GatewayManager: RemoteError = RemoteError - def __init__(self, specs): - self.specs = [py.execnet.XSpec(spec) for spec in specs] + def __init__(self, specs, defaultchdir="pyexecnetcache"): self.gateways = [] + self.specs = [] + for spec in specs: + if not isinstance(spec, py.execnet.XSpec): + spec = py.execnet.XSpec(spec) + if not spec.chdir and not spec.popen: + spec.chdir = defaultchdir + self.specs.append(spec) def trace(self, msg): self.notify("trace", "gatewaymanage", msg) diff --git a/py/execnet/testing/test_gwmanage.py b/py/execnet/testing/test_gwmanage.py index 62a669ffa..74a1b6716 100644 --- a/py/execnet/testing/test_gwmanage.py +++ b/py/execnet/testing/test_gwmanage.py @@ -11,6 +11,17 @@ from py.__.execnet.gwmanage import GatewayManager, HostRSync pytest_plugins = "pytest_pytester" class TestGatewayManagerPopen: + def test_popen_no_default_chdir(self): + gm = GatewayManager(["popen"]) + assert gm.specs[0].chdir is None + + def test_default_chdir(self): + l = ["ssh=noco", "socket=xyz"] + for spec in GatewayManager(l).specs: + assert spec.chdir == "pyexecnetcache" + for spec in GatewayManager(l, defaultchdir="abc").specs: + assert spec.chdir == "abc" + def test_hostmanager_popen_makegateway(self, eventrecorder): hm = GatewayManager(["popen"] * 2) hm.makegateways()