blob: 3aa271e8227b9efa2ab025d3489ea6fa24249ddb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
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
|