File: test_jsonrpc.txt

package info (click to toggle)
python-webob 1.1.1-1.1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 988 kB
  • sloc: python: 10,636; makefile: 43
file content (27 lines) | stat: -rw-r--r-- 887 bytes parent folder | download | duplicates (10)
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