[svn r63149] always have a default chdir

--HG--
branch : trunk
This commit is contained in:
hpk 2009-03-20 18:14:45 +01:00
parent 78d1836d80
commit c8da61a7d3
2 changed files with 19 additions and 2 deletions

View File

@ -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)

View File

@ -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()