[pypy-svn] r42185 - in pypy/branch/lib-distributed-rewrite/pypy/lib/distributed: . test

fijal at codespeak.net fijal at codespeak.net
Thu Apr 19 22:34:31 CEST 2007


Author: fijal
Date: Thu Apr 19 22:34:30 2007
New Revision: 42185

Modified:
   pypy/branch/lib-distributed-rewrite/pypy/lib/distributed/faker.py
   pypy/branch/lib-distributed-rewrite/pypy/lib/distributed/test/test_distributed.py
Log:
Success! The remote file works (even faked one)


Modified: pypy/branch/lib-distributed-rewrite/pypy/lib/distributed/faker.py
==============================================================================
--- pypy/branch/lib-distributed-rewrite/pypy/lib/distributed/faker.py	(original)
+++ pypy/branch/lib-distributed-rewrite/pypy/lib/distributed/faker.py	Thu Apr 19 22:34:30 2007
@@ -41,9 +41,9 @@
     care about descriptors
     """
     print "Wrapping type %s" % tp.__name__
-    if tp.__name__ == 'file':
-        import pdb
-        pdb.set_trace()
+    #if tp.__name__ == 'file':
+    #    import pdb
+    #    pdb.set_trace()
     # XXX forget about bases right now
     bases = []
     dict_w = {}
@@ -54,12 +54,13 @@
         if ignore(item):
             # we've got shortcut for method
             if hasattr(value, '__get__') and not type(value) is MethodType:
+                name = type(value).__name__
                 if hasattr(value, '__set__'):
-                    print "GetSet %s" % value.__name__
-                    dict_w[item] = ('get', value.__name__)
+                    print "GetSet %s" % name
+                    dict_w[item] = ('get', name)
                 else:
-                    print "Get %s" % value.__name__
-                    dict_w[item] = ('set', value.__name__)
+                    print "Get %s" % name
+                    dict_w[item] = ('set', name)
             else:
                 dict_w[item] = protocol.wrap(value)
     return tp_id, tp.__name__, dict_w, bases

Modified: pypy/branch/lib-distributed-rewrite/pypy/lib/distributed/test/test_distributed.py
==============================================================================
--- pypy/branch/lib-distributed-rewrite/pypy/lib/distributed/test/test_distributed.py	(original)
+++ pypy/branch/lib-distributed-rewrite/pypy/lib/distributed/test/test_distributed.py	Thu Apr 19 22:34:30 2007
@@ -253,3 +253,12 @@
         l = dir(s)
         assert l
 
+    def test_remote_file_access(self):
+        # cannot do test_env({'file':file}) yet :)
+        def f(name):
+            return open(name)
+
+        protocol = self.test_env({'f':f})
+        xf = protocol.get_remote('f')
+        data = xf('/etc/passwd').read()
+        assert data



More information about the Pypy-commit mailing list