Skip to content

Commit

Permalink
Merge branch 'master' into fix-11/xmlrpc-testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Howitz committed May 12, 2020
2 parents 4289f2f + eefef28 commit cf40294
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
beyond ASCII.
(`#11 <https://github.com/zopefoundation/zope.app.publisher/issues/11>`_)

- Support options *use_datetime* (Python >= 2.7) and *use_builtin_types*
(`Python >= 3.5`) in ``.xmlrpc.testing.ServerProxy``.


4.2.0 (2019-12-05)
==================
Expand Down
18 changes: 12 additions & 6 deletions src/zope/app/publisher/xmlrpc/testing.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
try:
import xmlrpclib
except ImportError:
except ImportError: # PY3
import xmlrpc.client as xmlrpclib

try:
import httplib
except ImportError:
except ImportError: # PY3
import http.client as httplib

from io import BytesIO
Expand Down Expand Up @@ -87,12 +87,18 @@ def request(self, host, handler, request_body, verbose=0):


def ServerProxy(wsgi_app, uri, transport=None, encoding=None,
verbose=0, allow_none=0, handleErrors=True):
"""A factory that creates a server proxy using the ZopeTestTransport
by default.
verbose=0, allow_none=0, handleErrors=True,
**transport_options):
"""A factory that creates a server proxy.
If ``transport`` is ``None`` use the ``ZopeTestTransport``, it gets
initialized with ``**transport_options``. Which options are supported
depends on the used Python version, see
``xmlrpc.client.Transport.__init__`` resp. ``xmlrpclib.Transport.__init__``
for details.
"""
if transport is None:
transport = ZopeTestTransport()
transport = ZopeTestTransport(**transport_options)
transport.wsgi_app = wsgi_app
if isinstance(transport, ZopeTestTransport):
transport.handleErrors = handleErrors
Expand Down

0 comments on commit cf40294

Please sign in to comment.