[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
					
				|  | @ -565,16 +565,22 @@ class SocketGatewaySetup: | |||
| ##        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") | ||||
|  |  | |||
|  | @ -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() | ||||
|  |  | |||
|  | @ -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  | ||||
|  |  | |||
|  | @ -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) | ||||
|  |  | |||
|  | @ -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)  | ||||
|  |  | |||
|  | @ -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):  | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue