[py-svn] r63137 - in py/trunk/py/execnet: . testing

hpk at codespeak.net hpk at codespeak.net
Fri Mar 20 14:41:44 CET 2009


Author: hpk
Date: Fri Mar 20 14:41:43 2009
New Revision: 63137

Modified:
   py/trunk/py/execnet/gateway.py
   py/trunk/py/execnet/testing/test_gateway.py
Log:
a helper some basic remote info 


Modified: py/trunk/py/execnet/gateway.py
==============================================================================
--- py/trunk/py/execnet/gateway.py	(original)
+++ py/trunk/py/execnet/gateway.py	Fri Mar 20 14:41:43 2009
@@ -241,6 +241,17 @@
         chan.setcallback(callback)
         return chan.id 
 
+    def _rinfo(self):
+        """ return some sys/env information from remote. """
+        return RInfo(**self.remote_exec("""
+            import sys, os
+            channel.send(dict(
+                executable = sys.executable, 
+                version_info = sys.version_info, 
+                curdir = os.getcwd(),
+            ))
+        """).receive())
+
     # _____________________________________________________________________
     #
     # High Level Interface
@@ -354,6 +365,9 @@
         if self._requestqueue is not None:
             self._requestqueue.put(None)
 
+class RInfo:
+    def __init__(self, **kwargs):
+        self.__dict__.update(kwargs)
 
 def getid(gw, cache={}):
     name = gw.__class__.__name__

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	Fri Mar 20 14:41:43 2009
@@ -441,6 +441,13 @@
         text = c1.receive()
         assert text.find("execution disallowed") != -1 
 
+    def test__rinfo(self):
+        rinfo = self.gw._rinfo()
+        assert rinfo.executable 
+        assert rinfo.curdir 
+        assert rinfo.version_info 
+        
+
 class BasicCmdbasedRemoteExecution(BasicRemoteExecution):
     def test_cmdattr(self):
         assert hasattr(self.gw, '_cmd')
@@ -480,7 +487,12 @@
 #        assert x == 17 
 
 class TestPopenGateway(PopenGatewayTestSetup, BasicRemoteExecution):
-    #disabled = True
+    def test_remote_info_popen(self):
+        rinfo = self.gw._rinfo()
+        assert rinfo.executable == py.std.sys.executable 
+        assert rinfo.curdir == py.std.os.getcwd()
+        assert rinfo.version_info == py.std.sys.version_info
+
     def test_chdir_separation(self):
         old = py.test.ensuretemp('chdirtest').chdir()
         try:



More information about the pytest-commit mailing list