Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
28 lines (26 sloc) 887 Bytes
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
You can’t perform that action at this time.