[Checkins] SVN: zope.app.testing/trunk/ Python 2.7 compatibility
Patrick Strawderman
patrick at zope.com
Thu Sep 2 11:05:04 EDT 2010
Log message for revision 116141:
Python 2.7 compatibility
Changed:
U zope.app.testing/trunk/CHANGES.txt
U zope.app.testing/trunk/src/zope/app/testing/xmlrpc.py
-=-
Modified: zope.app.testing/trunk/CHANGES.txt
===================================================================
--- zope.app.testing/trunk/CHANGES.txt 2010-09-02 13:59:21 UTC (rev 116140)
+++ zope.app.testing/trunk/CHANGES.txt 2010-09-02 15:05:04 UTC (rev 116141)
@@ -9,6 +9,8 @@
others testing without a referer and 'localhost' is not a reasonable
default anyway.) This improves the situation for #98437
+- Make the xmlrpc code compatible with Python 2.7.
+
3.7.5 (2010-04-10)
------------------
Modified: zope.app.testing/trunk/src/zope/app/testing/xmlrpc.py
===================================================================
--- zope.app.testing/trunk/src/zope/app/testing/xmlrpc.py 2010-09-02 13:59:21 UTC (rev 116140)
+++ zope.app.testing/trunk/src/zope/app/testing/xmlrpc.py 2010-09-02 15:05:04 UTC (rev 116141)
@@ -16,12 +16,22 @@
$Id$
"""
+import httplib
import StringIO
-import xmlrpclib
+import xmlrpclib
from zope.app.testing.functional import HTTPCaller
+class FakeSocket(object):
+
+ def __init__(self, data):
+ self.data = data
+
+ def makefile(self, mode, bufsize=None):
+ return StringIO.StringIO(self.data)
+
+
class ZopeTestTransport(xmlrpclib.Transport):
"""xmlrpclib transport that delegates to
zope.app.testing.functional.HTTPCaller.
@@ -58,11 +68,11 @@
errcode, errmsg,
headers
)
+ res = httplib.HTTPResponse(FakeSocket(response.getBody()))
+ res.begin()
+ return self.parse_response(res)
- return self._parse_response(
- StringIO.StringIO(response.getBody()), sock=None)
-
def ServerProxy(uri, transport=None, encoding=None,
verbose=0, allow_none=0, handleErrors=True):
"""A factory that creates a server proxy using the ZopeTestTransport
More information about the checkins
mailing list