[svn r63050] * disabled classes or modules will now lead to a skip during setup of the colitem
* more graceful handling when "ssh" is not present --HG-- branch : trunk
This commit is contained in:
parent
6ba07a82ba
commit
f013f0a54b
|
@ -564,17 +564,23 @@ class SocketGatewaySetup:
|
||||||
## def teardown_class(cls):
|
## def teardown_class(cls):
|
||||||
## cls.gw.exit()
|
## cls.gw.exit()
|
||||||
## cls.proxygw.exit()
|
## cls.proxygw.exit()
|
||||||
|
|
||||||
|
def getsshhost():
|
||||||
|
sshhost = py.test.config.getvalueorskip("sshhost")
|
||||||
|
if sshhost.find(":") != -1:
|
||||||
|
sshhost = sshhost.split(":")[0]
|
||||||
|
ssh = py.path.local.sysfind("ssh")
|
||||||
|
if not ssh:
|
||||||
|
py.test.skip("command not found: ssh")
|
||||||
|
return sshhost
|
||||||
|
|
||||||
class TestSocketGateway(SocketGatewaySetup, BasicRemoteExecution):
|
class TestSocketGateway(SocketGatewaySetup, BasicRemoteExecution):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class TestSshGateway(BasicRemoteExecution):
|
class TestSshGateway(BasicRemoteExecution):
|
||||||
def setup_class(cls):
|
def setup_class(cls):
|
||||||
sshhost = py.test.config.getvalueorskip("sshhost")
|
cls.sshhost = getsshhost()
|
||||||
if sshhost.find(":") != -1:
|
cls.gw = py.execnet.SshGateway(cls.sshhost)
|
||||||
sshhost = sshhost.split(":")[0]
|
|
||||||
cls.sshhost = sshhost
|
|
||||||
cls.gw = py.execnet.SshGateway(sshhost)
|
|
||||||
|
|
||||||
def test_sshconfig_functional(self):
|
def test_sshconfig_functional(self):
|
||||||
tmpdir = py.test.ensuretemp("test_sshconfig")
|
tmpdir = py.test.ensuretemp("test_sshconfig")
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import py
|
import py
|
||||||
|
from test_gateway import getsshhost
|
||||||
|
|
||||||
class TestGatewaySpec:
|
class TestGatewaySpec:
|
||||||
"""
|
"""
|
||||||
|
@ -88,7 +89,7 @@ class TestGatewaySpecAPI:
|
||||||
gw.exit()
|
gw.exit()
|
||||||
|
|
||||||
def test_ssh(self):
|
def test_ssh(self):
|
||||||
sshhost = py.test.config.getvalueorskip("sshhost")
|
sshhost = getsshhost()
|
||||||
spec = py.execnet.GatewaySpec("ssh:" + sshhost)
|
spec = py.execnet.GatewaySpec("ssh:" + sshhost)
|
||||||
gw = spec.makegateway()
|
gw = spec.makegateway()
|
||||||
p = gw.remote_exec("import os ; channel.send(os.getcwd())").receive()
|
p = gw.remote_exec("import os ; channel.send(os.getcwd())").receive()
|
||||||
|
|
|
@ -89,6 +89,7 @@ class HostManager(object):
|
||||||
for root in self.roots:
|
for root in self.roots:
|
||||||
self.gwmanager.rsync(root, **options)
|
self.gwmanager.rsync(root, **options)
|
||||||
else:
|
else:
|
||||||
|
XXX # do we want to care for situations without explicit rsyncdirs?
|
||||||
# we transfer our topdir as the root
|
# we transfer our topdir as the root
|
||||||
self.gwmanager.rsync(self.config.topdir, **options)
|
self.gwmanager.rsync(self.config.topdir, **options)
|
||||||
# and cd into it
|
# and cd into it
|
||||||
|
|
|
@ -31,8 +31,8 @@ class ExecnetcleanupPlugin:
|
||||||
for gw in self._gateways:
|
for gw in self._gateways:
|
||||||
gw.exit()
|
gw.exit()
|
||||||
l.append(gw)
|
l.append(gw)
|
||||||
for gw in l:
|
#for gw in l:
|
||||||
gw.join()
|
# gw.join()
|
||||||
|
|
||||||
def test_generic(plugintester):
|
def test_generic(plugintester):
|
||||||
plugintester.apicheck(ExecnetcleanupPlugin)
|
plugintester.apicheck(ExecnetcleanupPlugin)
|
||||||
|
|
|
@ -160,11 +160,6 @@ class PyCollectorMixin(PyobjMixin, py.test.collect.Collector):
|
||||||
return self.Function(name, parent=self)
|
return self.Function(name, parent=self)
|
||||||
|
|
||||||
class Module(py.test.collect.File, PyCollectorMixin):
|
class Module(py.test.collect.File, PyCollectorMixin):
|
||||||
def collect(self):
|
|
||||||
if self.fspath.ext == ".py" and getattr(self.obj, 'disabled', 0):
|
|
||||||
return []
|
|
||||||
return super(Module, self).collect()
|
|
||||||
|
|
||||||
def _getobj(self):
|
def _getobj(self):
|
||||||
return self._memoizedcall('_obj', self._importtestmodule)
|
return self._memoizedcall('_obj', self._importtestmodule)
|
||||||
|
|
||||||
|
@ -176,6 +171,8 @@ class Module(py.test.collect.File, PyCollectorMixin):
|
||||||
return mod
|
return mod
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
|
if getattr(self.obj, 'disabled', 0):
|
||||||
|
py.test.skip("%r is disabled" %(self.obj,))
|
||||||
if not self.config.option.nomagic:
|
if not self.config.option.nomagic:
|
||||||
#print "*" * 20, "INVOKE assertion", self
|
#print "*" * 20, "INVOKE assertion", self
|
||||||
py.magic.invoke(assertion=1)
|
py.magic.invoke(assertion=1)
|
||||||
|
@ -195,14 +192,14 @@ class Module(py.test.collect.File, PyCollectorMixin):
|
||||||
class Class(PyCollectorMixin, py.test.collect.Collector):
|
class Class(PyCollectorMixin, py.test.collect.Collector):
|
||||||
|
|
||||||
def collect(self):
|
def collect(self):
|
||||||
if getattr(self.obj, 'disabled', 0):
|
|
||||||
return []
|
|
||||||
l = self._deprecated_collect()
|
l = self._deprecated_collect()
|
||||||
if l is not None:
|
if l is not None:
|
||||||
return l
|
return l
|
||||||
return [self.Instance(name="()", parent=self)]
|
return [self.Instance(name="()", parent=self)]
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
|
if getattr(self.obj, 'disabled', 0):
|
||||||
|
py.test.skip("%r is disabled" %(self.obj,))
|
||||||
setup_class = getattr(self.obj, 'setup_class', None)
|
setup_class = getattr(self.obj, 'setup_class', None)
|
||||||
if setup_class is not None:
|
if setup_class is not None:
|
||||||
setup_class = getattr(setup_class, 'im_func', setup_class)
|
setup_class = getattr(setup_class, 'im_func', setup_class)
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import py
|
import py
|
||||||
|
|
||||||
|
from py.__.test.outcome import Skipped
|
||||||
|
|
||||||
class TestModule:
|
class TestModule:
|
||||||
def test_module_file_not_found(self, testdir):
|
def test_module_file_not_found(self, testdir):
|
||||||
tmpdir = testdir.tmpdir
|
tmpdir = testdir.tmpdir
|
||||||
|
@ -38,15 +40,6 @@ class TestModule:
|
||||||
x = l.pop()
|
x = l.pop()
|
||||||
assert x is None
|
assert x is None
|
||||||
|
|
||||||
def test_disabled_module(self, testdir):
|
|
||||||
modcol = testdir.getmodulecol("""
|
|
||||||
disabled = True
|
|
||||||
def setup_module(mod):
|
|
||||||
raise ValueError
|
|
||||||
""")
|
|
||||||
assert not modcol.collect()
|
|
||||||
assert not modcol.run()
|
|
||||||
|
|
||||||
def test_module_participates_as_plugin(self, testdir):
|
def test_module_participates_as_plugin(self, testdir):
|
||||||
modcol = testdir.getmodulecol("")
|
modcol = testdir.getmodulecol("")
|
||||||
modcol.setup()
|
modcol.setup()
|
||||||
|
@ -58,6 +51,18 @@ class TestModule:
|
||||||
modcol = testdir.getmodulecol("pytest_plugins='xasdlkj',")
|
modcol = testdir.getmodulecol("pytest_plugins='xasdlkj',")
|
||||||
py.test.raises(ImportError, "modcol.obj")
|
py.test.raises(ImportError, "modcol.obj")
|
||||||
|
|
||||||
|
def test_disabled_module(self, testdir):
|
||||||
|
modcol = testdir.getmodulecol("""
|
||||||
|
disabled = True
|
||||||
|
def setup_module(mod):
|
||||||
|
raise ValueError
|
||||||
|
def test_method():
|
||||||
|
pass
|
||||||
|
""")
|
||||||
|
l = modcol.collect()
|
||||||
|
assert len(l) == 1
|
||||||
|
py.test.raises(Skipped, "modcol.setup()")
|
||||||
|
|
||||||
class TestClass:
|
class TestClass:
|
||||||
def test_disabled_class(self, testdir):
|
def test_disabled_class(self, testdir):
|
||||||
modcol = testdir.getmodulecol("""
|
modcol = testdir.getmodulecol("""
|
||||||
|
@ -70,7 +75,9 @@ class TestClass:
|
||||||
assert len(l) == 1
|
assert len(l) == 1
|
||||||
modcol = l[0]
|
modcol = l[0]
|
||||||
assert isinstance(modcol, py.test.collect.Class)
|
assert isinstance(modcol, py.test.collect.Class)
|
||||||
assert not modcol.collect()
|
l = modcol.collect()
|
||||||
|
assert len(l) == 1
|
||||||
|
py.test.raises(Skipped, "modcol.setup()")
|
||||||
|
|
||||||
class TestGenerator:
|
class TestGenerator:
|
||||||
def test_generative_functions(self, testdir):
|
def test_generative_functions(self, testdir):
|
||||||
|
|
Loading…
Reference in New Issue