def test_jsonrpc_input_string(live_server): c = HTTPClient(live_server.url + '/all-rpc/') # Python 2 : "<type 'str'>" # Python 3 : "<class 'str'>" # By default on Python 2, json-rpc call to this method will return 'unicode' # This test suite has been configured with settings.MODERNRPC_PY2_STR_TYPE = str, so # arguments passed to RPC methods via XML or JSON will be converted to the same type (str in that case) assert re.match(r"<(class|type) 'str'>", c.get_data_type('abcd'))
def test_jsonrpc_date_2(live_server): c = HTTPClient(live_server.url + '/all-rpc/') date = datetime.datetime(1990, 1, 1, 0, 0, 0) # Since date type is not supported by JSON-RPC spec, it is transported as string # to the server. By default, the decoded type depends on the Python version. # Since this test suite has been configured with settings.MODERNRPC_PY2_STR_TYPE = str, # the type returned will always be 'str' # We have to convert date to ISO 8601, since JSON-RPC cannot serialize it assert re.match(r"<(class|type) 'str'>", c.get_data_type(date.isoformat()))