[py-svn] r63091 - in py/trunk/py: execnet execnet/testing test/dsession test/dsession/testing test/plugin

hpk at codespeak.net hpk at codespeak.net
Thu Mar 19 19:25:15 CET 2009


Author: hpk
Date: Thu Mar 19 19:25:13 2009
New Revision: 63091

Modified:
   py/trunk/py/execnet/gwmanage.py
   py/trunk/py/execnet/testing/test_gateway.py
   py/trunk/py/execnet/testing/test_gwmanage.py
   py/trunk/py/test/dsession/hostmanage.py
   py/trunk/py/test/dsession/testing/test_functional_dsession.py
   py/trunk/py/test/dsession/testing/test_hostmanage.py
   py/trunk/py/test/plugin/pytest_plugintester.py
   py/trunk/py/test/plugin/pytest_terminal.py
Log:
report some more info on dist-setup 
shift comments


Modified: py/trunk/py/execnet/gwmanage.py
==============================================================================
--- py/trunk/py/execnet/gwmanage.py	(original)
+++ py/trunk/py/execnet/gwmanage.py	Thu Mar 19 19:25:13 2009
@@ -26,6 +26,7 @@
 class GatewaySpec(object):
     python = None
     def __init__(self, spec, defaultjoinpath="pyexecnetcache"):
+        self._spec = spec
         if spec == "popen" or spec.startswith("popen:"):
             parts = spec.split(":", 2)
             self.type = self.address = parts.pop(0)
@@ -66,7 +67,7 @@
         return bool(self.type == "popen" and not self.joinpath)
 
     def __str__(self):
-        return "<GatewaySpec %s:%s>" % (self.address, self.joinpath)
+        return "<GatewaySpec %s>" % self._spec
     __repr__ = __str__
 
     def makegateway(self, waitclose=True):
@@ -102,13 +103,18 @@
         self.gateways = []
 
     def trace(self, msg):
-        py._com.pyplugins.notify("trace", "gatewaymanage", msg)
+        self.notify("trace", "gatewaymanage", msg)
+
+    def notify(self, eventname, *args, **kwargs):
+        py._com.pyplugins.notify(eventname, *args, **kwargs)
 
     def makegateways(self):
         assert not self.gateways
         for spec in self.specs:
-            self.trace("makegateway %s" %(spec))
-            self.gateways.append(spec.makegateway())
+            gw = spec.makegateway()
+            self.gateways.append(gw)
+            gw.id = "[%s]" % len(self.gateways)
+            self.notify("gwmanage_newgateway", gw)
 
     def getgateways(self, remote=True, inplacelocal=True):
         if not self.gateways and self.specs:

Modified: py/trunk/py/execnet/testing/test_gateway.py
==============================================================================
--- py/trunk/py/execnet/testing/test_gateway.py	(original)
+++ py/trunk/py/execnet/testing/test_gateway.py	Thu Mar 19 19:25:13 2009
@@ -565,9 +565,9 @@
 ##        cls.gw.exit()
 ##        cls.proxygw.exit()
        
-def getsshhost():
+def getsshhost(withpython=False):
     sshhost = py.test.config.getvalueorskip("sshhost")
-    if sshhost.find(":") != -1:
+    if not withpython and sshhost.find(":") != -1:
         sshhost = sshhost.split(":")[0]
     ssh = py.path.local.sysfind("ssh")
     if not ssh:

Modified: py/trunk/py/execnet/testing/test_gwmanage.py
==============================================================================
--- py/trunk/py/execnet/testing/test_gwmanage.py	(original)
+++ py/trunk/py/execnet/testing/test_gwmanage.py	Thu Mar 19 19:25:13 2009
@@ -1,7 +1,5 @@
 """ 
     tests for 
-    - gateway specifications
-    - multi channels and multi gateways 
     - gateway management 
     - manage rsyncing of hosts 
 
@@ -10,10 +8,18 @@
 import py
 from py.__.execnet.gwmanage import GatewayManager, HostRSync
 
+pytest_plugins = "pytest_pytester"
+
 class TestGatewayManagerPopen:
-    def test_hostmanager_popen_makegateway(self):
+    def test_hostmanager_popen_makegateway(self, eventrecorder):
         hm = GatewayManager(["popen"] * 2)
         hm.makegateways()
+        event = eventrecorder.popevent("gwmanage_newgateway")
+        gw = event.args[0]
+        assert gw.id == "[1]" 
+        event = eventrecorder.popevent("gwmanage_newgateway")
+        gw = event.args[0]
+        assert gw.id == "[2]" 
         assert len(hm.gateways) == 2
         hm.exit()
         assert not len(hm.gateways) 

Modified: py/trunk/py/test/dsession/hostmanage.py
==============================================================================
--- py/trunk/py/test/dsession/hostmanage.py	(original)
+++ py/trunk/py/test/dsession/hostmanage.py	Thu Mar 19 19:25:13 2009
@@ -50,6 +50,11 @@
         self.gwmanager = GatewayManager(hosts)
 
     def makegateways(self):
+        # we change to the topdir sot that 
+        # PopenGateways will have their cwd 
+        # such that unpickling configs will 
+        # pick it up as the right topdir 
+        # (for other gateways this chdir is irrelevant)
         old = self.config.topdir.chdir()  
         try:
             self.gwmanager.makegateways()
@@ -74,11 +79,6 @@
             have the same set of roots in their
             current directory. 
         """
-        # we change to the topdir sot that 
-        # PopenGateways will have their cwd 
-        # such that unpickling configs will 
-        # pick it up as the right topdir 
-        # (for other gateways this chdir is irrelevant)
         self.makegateways()
         options = {
             'ignores': self.config_getignores(), 

Modified: py/trunk/py/test/dsession/testing/test_functional_dsession.py
==============================================================================
--- py/trunk/py/test/dsession/testing/test_functional_dsession.py	(original)
+++ py/trunk/py/test/dsession/testing/test_functional_dsession.py	Thu Mar 19 19:25:13 2009
@@ -65,9 +65,12 @@
         p = subdir.join("test_one.py")
         p.write("def test_5(): assert not __file__.startswith(%r)" % str(p))
         result = testdir.runpytest("-d", "--rsyncdirs=%(subdir)s" % locals(), 
-                                   "--gateways=popen::%(dest)s" % locals(), p)
+            "--gateways=popen::%(dest)s" % locals(), p)
         assert result.ret == 0
         result.stdout.fnmatch_lines([
+            "*1* instantiated gateway *popen*",
+            #"RSyncStart: [G1]",
+            #"RSyncFinished: [G1]",
             "*1 passed*"
         ])
         assert dest.join(subdir.basename).check(dir=1)

Modified: py/trunk/py/test/dsession/testing/test_hostmanage.py
==============================================================================
--- py/trunk/py/test/dsession/testing/test_hostmanage.py	(original)
+++ py/trunk/py/test/dsession/testing/test_hostmanage.py	Thu Mar 19 19:25:13 2009
@@ -136,7 +136,7 @@
         hm.teardown_hosts()
 
     def test_hostmanage_ssh_setup_hosts(self, testdir):
-        sshhost = getsshhost()
+        sshhost = getsshhost(withpython=True)
         testdir.makepyfile(__init__="", test_x="""
             def test_one():
                 pass
@@ -149,7 +149,7 @@
 
     @py.test.mark.xfail("implement double-rsync test")
     def test_ssh_rsync_samehost_twice(self):
-        sshhost = getsshhost()
+        sshhost = getsshhost(withpython=True)
         host1 = Host("%s" % (sshhost, ))
         host2 = Host("%s" % (sshhost, ))
         hm = HostManager(config, hosts=[host1, host2])

Modified: py/trunk/py/test/plugin/pytest_plugintester.py
==============================================================================
--- py/trunk/py/test/plugin/pytest_plugintester.py	(original)
+++ py/trunk/py/test/plugin/pytest_plugintester.py	Thu Mar 19 19:25:13 2009
@@ -186,7 +186,13 @@
         """ whole test run starts. """
 
     def pyevent_testrunfinish(self, event):
-        """ whole test run starts. """
+        """ whole test run finishes. """
+
+    def pyevent_gwmanage_newgateway(self, gateway):
+        """ execnet gateway manager has instantiated a gateway. 
+            The gateway will have an 'id' attribute that is unique 
+            within the gateway manager context. 
+        """
 
     def pyevent_hostup(self, event):
         """ Host is up. """

Modified: py/trunk/py/test/plugin/pytest_terminal.py
==============================================================================
--- py/trunk/py/test/plugin/pytest_terminal.py	(original)
+++ py/trunk/py/test/plugin/pytest_terminal.py	Thu Mar 19 19:25:13 2009
@@ -84,6 +84,9 @@
         for line in str(event.repr).split("\n"):
             self.write_line("InternalException: " + line)
 
+    def pyevent_gwmanage_newgateway(self, gateway):
+        self.write_line("%s instantiated gateway from spec %r" %(gateway.id, gateway.spec._spec))
+
     def pyevent_hostgatewayready(self, event):
         if self.config.option.verbose:
             self.write_line("HostGatewayReady: %s" %(event.host,))



More information about the pytest-commit mailing list