Sophie

Sophie

distrib > Fedora > 19 > i386 > by-pkgid > 88c6b91532eec97925667bc9bf1e5c96 > files > 77

python-webob-1.2.3-8.fc19.noarch.rpm

This is a test of the ``jsonrpc.py`` module::

    >>> class Divider(object):
    ...     def divide(self, a, b):
    ...        return a / b
    >>> from jsonrpc import *
    >>> app = JsonRpcApp(Divider())
    >>> proxy = ServerProxy('http://localhost:8080', proxy=app)
    >>> proxy.divide(10, 4)
    2
    >>> proxy.divide(10, 4.0)
    2.5
    >>> proxy.divide(10, 0) # doctest: +ELLIPSIS
    Traceback (most recent call last):
       ...
    Fault: Method error calling http://localhost:8080: integer division or modulo by zero
    Traceback (most recent call last):
      File ...
        result = method(*params)
      File ...
        return a / b
    ZeroDivisionError: integer division or modulo by zero
    <BLANKLINE>
    >>> proxy.add(1, 1)
    Traceback (most recent call last):
        ...
    ProxyError: Error from JSON-RPC client http://localhost:8080: 400 Bad Request