diff --git a/py/execnet/testing/test_gateway.py b/py/execnet/testing/test_gateway.py index a3f243715..1270a0dd4 100644 --- a/py/execnet/testing/test_gateway.py +++ b/py/execnet/testing/test_gateway.py @@ -564,17 +564,23 @@ class SocketGatewaySetup: ## def teardown_class(cls): ## cls.gw.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): pass class TestSshGateway(BasicRemoteExecution): def setup_class(cls): - sshhost = py.test.config.getvalueorskip("sshhost") - if sshhost.find(":") != -1: - sshhost = sshhost.split(":")[0] - cls.sshhost = sshhost - cls.gw = py.execnet.SshGateway(sshhost) + cls.sshhost = getsshhost() + cls.gw = py.execnet.SshGateway(cls.sshhost) def test_sshconfig_functional(self): tmpdir = py.test.ensuretemp("test_sshconfig") diff --git a/py/execnet/testing/test_gwspec.py b/py/execnet/testing/test_gwspec.py index 3bcf5ff54..de1b7f2bf 100644 --- a/py/execnet/testing/test_gwspec.py +++ b/py/execnet/testing/test_gwspec.py @@ -3,6 +3,7 @@ """ import py +from test_gateway import getsshhost class TestGatewaySpec: """ @@ -88,7 +89,7 @@ class TestGatewaySpecAPI: gw.exit() def test_ssh(self): - sshhost = py.test.config.getvalueorskip("sshhost") + sshhost = getsshhost() spec = py.execnet.GatewaySpec("ssh:" + sshhost) gw = spec.makegateway() p = gw.remote_exec("import os ; channel.send(os.getcwd())").receive() diff --git a/py/test/dsession/hostmanage.py b/py/test/dsession/hostmanage.py index badf9f1cf..f8f579c4f 100644 --- a/py/test/dsession/hostmanage.py +++ b/py/test/dsession/hostmanage.py @@ -89,6 +89,7 @@ class HostManager(object): for root in self.roots: self.gwmanager.rsync(root, **options) else: + XXX # do we want to care for situations without explicit rsyncdirs? # we transfer our topdir as the root self.gwmanager.rsync(self.config.topdir, **options) # and cd into it diff --git a/py/test/plugin/pytest_execnetcleanup.py b/py/test/plugin/pytest_execnetcleanup.py index 807e16e24..a40a1adc2 100644 --- a/py/test/plugin/pytest_execnetcleanup.py +++ b/py/test/plugin/pytest_execnetcleanup.py @@ -31,8 +31,8 @@ class ExecnetcleanupPlugin: for gw in self._gateways: gw.exit() l.append(gw) - for gw in l: - gw.join() + #for gw in l: + # gw.join() def test_generic(plugintester): plugintester.apicheck(ExecnetcleanupPlugin) diff --git a/py/test/pycollect.py b/py/test/pycollect.py index e92979864..28b6d0177 100644 --- a/py/test/pycollect.py +++ b/py/test/pycollect.py @@ -160,11 +160,6 @@ class PyCollectorMixin(PyobjMixin, py.test.collect.Collector): return self.Function(name, parent=self) 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): return self._memoizedcall('_obj', self._importtestmodule) @@ -176,6 +171,8 @@ class Module(py.test.collect.File, PyCollectorMixin): return mod def setup(self): + if getattr(self.obj, 'disabled', 0): + py.test.skip("%r is disabled" %(self.obj,)) if not self.config.option.nomagic: #print "*" * 20, "INVOKE assertion", self py.magic.invoke(assertion=1) @@ -195,14 +192,14 @@ class Module(py.test.collect.File, PyCollectorMixin): class Class(PyCollectorMixin, py.test.collect.Collector): def collect(self): - if getattr(self.obj, 'disabled', 0): - return [] l = self._deprecated_collect() if l is not None: return l return [self.Instance(name="()", parent=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) if setup_class is not None: setup_class = getattr(setup_class, 'im_func', setup_class) diff --git a/py/test/testing/test_pycollect.py b/py/test/testing/test_pycollect.py index 7297aeba7..b5d9033dd 100644 --- a/py/test/testing/test_pycollect.py +++ b/py/test/testing/test_pycollect.py @@ -1,5 +1,7 @@ import py +from py.__.test.outcome import Skipped + class TestModule: def test_module_file_not_found(self, testdir): tmpdir = testdir.tmpdir @@ -38,15 +40,6 @@ class TestModule: x = l.pop() 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): modcol = testdir.getmodulecol("") modcol.setup() @@ -58,6 +51,18 @@ class TestModule: modcol = testdir.getmodulecol("pytest_plugins='xasdlkj',") 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: def test_disabled_class(self, testdir): modcol = testdir.getmodulecol(""" @@ -70,7 +75,9 @@ class TestClass: assert len(l) == 1 modcol = l[0] 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: def test_generative_functions(self, testdir):