How to use jsonrpc method in uiautomator

Best Python code snippet using uiautomator

test_middlewares.py

Source:test_middlewares.py Github

copy

Full Screen

1import contextlib2import contextvars3import logging4import sys5import uuid6from collections import defaultdict7from typing import Tuple8import pytest9from fastapi import Body10import fastapi_jsonrpc as jsonrpc11unique_marker = str(uuid.uuid4())12unique_marker2 = str(uuid.uuid4())13class TestError(jsonrpc.BaseError):14 CODE = 3333315 MESSAGE = "Test error"16@pytest.fixture17def ep(ep_path):18 _calls = defaultdict(list)19 ep_middleware_var = contextvars.ContextVar('ep_middleware')20 method_middleware_var = contextvars.ContextVar('method_middleware')21 @contextlib.asynccontextmanager22 async def ep_handle_exception(_ctx: jsonrpc.JsonRpcContext):23 try:24 yield25 except RuntimeError as exc:26 logging.exception(str(exc), exc_info=exc)27 raise TestError(unique_marker2)28 @contextlib.asynccontextmanager29 async def ep_middleware(ctx: jsonrpc.JsonRpcContext):30 nonlocal _calls31 ep_middleware_var.set('ep_middleware-value')32 _calls[ctx.raw_request.get('id')].append((33 'ep_middleware', 'enter', ctx.raw_request, ctx.raw_response, sys.exc_info()[0]34 ))35 try:36 yield37 finally:38 _calls[ctx.raw_response.get('id')].append((39 'ep_middleware', 'exit', ctx.raw_request, ctx.raw_response, sys.exc_info()[0]40 ))41 @contextlib.asynccontextmanager42 async def method_middleware(ctx):43 nonlocal _calls44 method_middleware_var.set('method_middleware-value')45 _calls[ctx.raw_request.get('id')].append((46 'method_middleware', 'enter', ctx.raw_request, ctx.raw_response, sys.exc_info()[0]47 ))48 try:49 yield50 finally:51 _calls[ctx.raw_response.get('id')].append((52 'method_middleware', 'exit', ctx.raw_request, ctx.raw_response, sys.exc_info()[0]53 ))54 ep = jsonrpc.Entrypoint(55 ep_path,56 middlewares=[ep_handle_exception, ep_middleware],57 )58 @ep.method(middlewares=[method_middleware])59 def probe(60 data: str = Body(..., example='123'),61 ) -> str:62 return data63 @ep.method(middlewares=[method_middleware])64 def probe_error(65 ) -> str:66 raise RuntimeError(unique_marker)67 @ep.method(middlewares=[method_middleware])68 def probe_context_vars(69 ) -> Tuple[str, str]:70 return ep_middleware_var.get(), method_middleware_var.get()71 ep.calls = _calls72 return ep73def test_single(ep, method_request):74 resp = method_request('probe', {'data': 'one'}, request_id=111)75 assert resp == {'id': 111, 'jsonrpc': '2.0', 'result': 'one'}76 assert ep.calls == {77 111: [78 (79 'ep_middleware',80 'enter',81 {82 'id': 111,83 'jsonrpc': '2.0',84 'method': 'probe',85 'params': {'data': 'one'},86 },87 None,88 None,89 ),90 (91 'method_middleware',92 'enter',93 {94 'id': 111,95 'jsonrpc': '2.0',96 'method': 'probe',97 'params': {'data': 'one'}98 },99 None,100 None,101 ),102 (103 'method_middleware',104 'exit',105 {106 'id': 111,107 'jsonrpc': '2.0',108 'method': 'probe',109 'params': {'data': 'one'}110 },111 {'id': 111, 'jsonrpc': '2.0', 'result': 'one'},112 None,113 ),114 (115 'ep_middleware',116 'exit',117 {118 'id': 111,119 'jsonrpc': '2.0',120 'method': 'probe',121 'params': {'data': 'one'}122 },123 {'id': 111, 'jsonrpc': '2.0', 'result': 'one'},124 None,125 )126 ]127 }128def test_single_error(ep, method_request, assert_log_errors):129 resp = method_request('probe_error', {'data': 'one'}, request_id=111)130 assert resp == {131 'id': 111, 'jsonrpc': '2.0', 'error': {132 'code': 33333, 'data': unique_marker2, 'message': 'Test error',133 }134 }135 assert ep.calls == {136 111: [137 (138 'ep_middleware',139 'enter',140 {141 'id': 111,142 'jsonrpc': '2.0',143 'method': 'probe_error',144 'params': {'data': 'one'},145 },146 None,147 None,148 ),149 (150 'method_middleware',151 'enter',152 {153 'id': 111,154 'jsonrpc': '2.0',155 'method': 'probe_error',156 'params': {'data': 'one'}157 },158 None,159 None,160 ),161 (162 'method_middleware',163 'exit',164 {165 'id': 111,166 'jsonrpc': '2.0',167 'method': 'probe_error',168 'params': {'data': 'one'}169 },170 {'id': 111, 'jsonrpc': '2.0', 'error': {'code': -32603, 'message': 'Internal error'}},171 RuntimeError,172 ),173 (174 'ep_middleware',175 'exit',176 {177 'id': 111,178 'jsonrpc': '2.0',179 'method': 'probe_error',180 'params': {'data': 'one'}181 },182 {'id': 111, 'jsonrpc': '2.0', 'error': {'code': -32603, 'message': 'Internal error'}},183 RuntimeError,184 )185 ]186 }187 assert_log_errors(unique_marker, pytest.raises(RuntimeError))188def test_batch(ep, json_request):189 resp = json_request([190 {191 'id': 111,192 'jsonrpc': '2.0',193 'method': 'probe',194 'params': {'data': 'one'},195 },196 {197 'id': 222,198 'jsonrpc': '2.0',199 'method': 'probe',200 'params': {'data': 'two'},201 },202 ])203 assert resp == [204 {'id': 111, 'jsonrpc': '2.0', 'result': 'one'},205 {'id': 222, 'jsonrpc': '2.0', 'result': 'two'},206 ]207 assert ep.calls == {208 111: [209 (210 'ep_middleware',211 'enter',212 {213 'id': 111,214 'jsonrpc': '2.0',215 'method': 'probe',216 'params': {'data': 'one'},217 },218 None,219 None,220 ),221 (222 'method_middleware',223 'enter',224 {225 'id': 111,226 'jsonrpc': '2.0',227 'method': 'probe',228 'params': {'data': 'one'}229 },230 None,231 None,232 ),233 (234 'method_middleware',235 'exit',236 {237 'id': 111,238 'jsonrpc': '2.0',239 'method': 'probe',240 'params': {'data': 'one'}241 },242 {'id': 111, 'jsonrpc': '2.0', 'result': 'one'},243 None,244 ),245 (246 'ep_middleware',247 'exit',248 {249 'id': 111,250 'jsonrpc': '2.0',251 'method': 'probe',252 'params': {'data': 'one'}253 },254 {'id': 111, 'jsonrpc': '2.0', 'result': 'one'},255 None,256 )257 ],258 222: [259 (260 'ep_middleware',261 'enter',262 {263 'id': 222,264 'jsonrpc': '2.0',265 'method': 'probe',266 'params': {'data': 'two'},267 },268 None,269 None,270 ),271 (272 'method_middleware',273 'enter',274 {275 'id': 222,276 'jsonrpc': '2.0',277 'method': 'probe',278 'params': {'data': 'two'}279 },280 None,281 None,282 ),283 (284 'method_middleware',285 'exit',286 {287 'id': 222,288 'jsonrpc': '2.0',289 'method': 'probe',290 'params': {'data': 'two'}291 },292 {'id': 222, 'jsonrpc': '2.0', 'result': 'two'},293 None,294 ),295 (296 'ep_middleware',297 'exit',298 {299 'id': 222,300 'jsonrpc': '2.0',301 'method': 'probe',302 'params': {'data': 'two'}303 },304 {'id': 222, 'jsonrpc': '2.0', 'result': 'two'},305 None,306 )307 ]308 }309def test_batch_error(ep, json_request, assert_log_errors):310 resp = json_request([311 {312 'id': 111,313 'jsonrpc': '2.0',314 'method': 'probe_error',315 'params': {'data': 'one'},316 },317 {318 'id': 222,319 'jsonrpc': '2.0',320 'method': 'probe_error',321 'params': {'data': 'two'},322 },323 ])324 assert resp == [325 {326 'id': 111, 'jsonrpc': '2.0', 'error': {327 'code': 33333, 'data': unique_marker2, 'message': 'Test error',328 }329 },330 {331 'id': 222, 'jsonrpc': '2.0', 'error': {332 'code': 33333, 'data': unique_marker2, 'message': 'Test error',333 }334 },335 ]336 assert ep.calls == {337 111: [338 (339 'ep_middleware',340 'enter',341 {342 'id': 111,343 'jsonrpc': '2.0',344 'method': 'probe_error',345 'params': {'data': 'one'},346 },347 None,348 None,349 ),350 (351 'method_middleware',352 'enter',353 {354 'id': 111,355 'jsonrpc': '2.0',356 'method': 'probe_error',357 'params': {'data': 'one'}358 },359 None,360 None,361 ),362 (363 'method_middleware',364 'exit',365 {366 'id': 111,367 'jsonrpc': '2.0',368 'method': 'probe_error',369 'params': {'data': 'one'}370 },371 {'id': 111, 'jsonrpc': '2.0', 'error': {'code': -32603, 'message': 'Internal error'}},372 RuntimeError,373 ),374 (375 'ep_middleware',376 'exit',377 {378 'id': 111,379 'jsonrpc': '2.0',380 'method': 'probe_error',381 'params': {'data': 'one'}382 },383 {'id': 111, 'jsonrpc': '2.0', 'error': {'code': -32603, 'message': 'Internal error'}},384 RuntimeError,385 )386 ],387 222: [388 (389 'ep_middleware',390 'enter',391 {392 'id': 222,393 'jsonrpc': '2.0',394 'method': 'probe_error',395 'params': {'data': 'two'},396 },397 None,398 None,399 ),400 (401 'method_middleware',402 'enter',403 {404 'id': 222,405 'jsonrpc': '2.0',406 'method': 'probe_error',407 'params': {'data': 'two'}408 },409 None,410 None,411 ),412 (413 'method_middleware',414 'exit',415 {416 'id': 222,417 'jsonrpc': '2.0',418 'method': 'probe_error',419 'params': {'data': 'two'}420 },421 {'id': 222, 'jsonrpc': '2.0', 'error': {'code': -32603, 'message': 'Internal error'}},422 RuntimeError,423 ),424 (425 'ep_middleware',426 'exit',427 {428 'id': 222,429 'jsonrpc': '2.0',430 'method': 'probe_error',431 'params': {'data': 'two'}432 },433 {'id': 222, 'jsonrpc': '2.0', 'error': {'code': -32603, 'message': 'Internal error'}},434 RuntimeError,435 )436 ]437 }438 assert_log_errors(439 unique_marker, pytest.raises(RuntimeError),440 unique_marker, pytest.raises(RuntimeError),441 )442def test_context_vars(ep, method_request):443 resp = method_request('probe_context_vars', {}, request_id=111)...

Full Screen

Full Screen

test_jsonrpc.py

Source:test_jsonrpc.py Github

copy

Full Screen

1import os2import pytest3from pyircbot import jsonrpc4from threading import Thread5from random import randint6from time import sleep7# Sample server methods8def sample(value):9 return value10class _sample(object):11 def sample(self, value):12 return value13def client(port, v=2):14 return jsonrpc.ServerProxy((jsonrpc.JsonRpc20 if v == 2 else jsonrpc.JsonRpc10)(),15 jsonrpc.TransportTcpIp(addr=("127.0.0.1", port), timeout=2.0))16# Fixures for each server version provide a (server_instance, port) tuple.17# Each have the method "sample", which returns the value passed18# Each have a class instance registered as "obj", which the method "sample" as well19@pytest.fixture20def j1testserver():21 port = randint(40000, 60000)22 server = jsonrpc.Server(jsonrpc.JsonRpc10(),23 jsonrpc.TransportTcpIp(addr=("127.0.0.1", port)))24 server.register_function(sample)25 server.register_instance(_sample(), name="obj")26 Thread(target=server.serve, daemon=True).start()27 sleep(0.1) # Give the serve() time to set up the serversocket28 yield (server, port)29 server._Server__transport.close()30@pytest.fixture31def j2testserver():32 port = randint(40000, 60000)33 server = jsonrpc.Server(jsonrpc.JsonRpc20(),34 jsonrpc.TransportTcpIp(addr=("127.0.0.1", port)))35 server.register_function(sample)36 server.register_instance(_sample(), name="obj")37 Thread(target=server.serve, daemon=True).start()38 sleep(0.2) # Give the serve() time to set up the serversocket39 yield (server, port)40 server._Server__transport.close()41# Basic functionality42def test_1_basic(j1testserver):43 str(jsonrpc.RPCFault(-32700, "foo", "bar"))44 server, port = j1testserver45 str(client(port, v=1))46 ret = client(port, v=1).sample("foobar")47 assert ret == "foobar"48def test_2_basic(j2testserver):49 server, port = j2testserver50 str(client(port))51 ret = client(port).sample("foobar")52 assert ret == "foobar"53def test_1_instance(j1testserver):54 server, port = j1testserver55 ret = client(port, v=1).obj.sample("foobar")56 assert ret == "foobar"57def test_2_instance(j2testserver):58 server, port = j2testserver59 ret = client(port).obj.sample("foobar")60 assert ret == "foobar"61# Missing methods raise clean error62def test_1_notfound(j1testserver):63 server, port = j1testserver64 with pytest.raises(jsonrpc.RPCMethodNotFound):65 client(port, v=1).idontexist("f")66 with pytest.raises(jsonrpc.RPCMethodNotFound):67 client(port, v=1).neither.idontexist("f")68def test_2_notfound(j2testserver):69 server, port = j2testserver70 with pytest.raises(jsonrpc.RPCMethodNotFound):71 client(port).idontexist("f")72 with pytest.raises(jsonrpc.RPCMethodNotFound):73 client(port).neither.idontexist("f")74# Underscore methods are blocked75def test_1_underscore():76 with pytest.raises(AttributeError):77 client(-1)._notallowed()78def test_2_underscore():79 with pytest.raises(AttributeError):80 client(-1)._notallowed()81# Response parsing hardness82def _test_1_protocol_parse_base(method):83 with pytest.raises(jsonrpc.RPCParseError): # Not json84 method("")85 with pytest.raises(jsonrpc.RPCInvalidRPC): # Not a dict86 method("[]")87 with pytest.raises(jsonrpc.RPCInvalidRPC): # Missing 'id'88 method("{}")89 with pytest.raises(jsonrpc.RPCInvalidRPC): # not 3 fields90 method('{"id": 0, "baz": 0}')91def _test_2_protocol_parse_base(method):92 with pytest.raises(jsonrpc.RPCParseError): # Not json93 method("")94 with pytest.raises(jsonrpc.RPCInvalidRPC): # Not a dict95 method("[]")96 with pytest.raises(jsonrpc.RPCInvalidRPC): # missing jsonrpc97 method('{}')98 with pytest.raises(jsonrpc.RPCInvalidRPC): # jsonrpc must be str99 method('{"jsonrpc": 1}')100 with pytest.raises(jsonrpc.RPCInvalidRPC): # jsonrpc must be "2.0"101 method('{"jsonrpc": "2.1"}')102def test_1_invalid_response():103 j = jsonrpc.JsonRpc10()104 _test_1_protocol_parse_base(j.loads_response)105 with pytest.raises(jsonrpc.RPCInvalidRPC): # can't have result and error106 j.loads_response('{"id": 0, "result": 1, "error": 0}')107def test_2_invalid_response():108 j = jsonrpc.JsonRpc20()109 _test_2_protocol_parse_base(j.loads_response)110 with pytest.raises(jsonrpc.RPCInvalidRPC): # Missing 'id'111 j.loads_response('{"jsonrpc": "2.0"}')112 with pytest.raises(jsonrpc.RPCInvalidRPC): # not 4 fields113 j.loads_response('{"id": 0, "jsonrpc": "2.0", "bar": 1}')114 with pytest.raises(jsonrpc.RPCInvalidRPC): # can't have result and error115 j.loads_response('{"id": 0, "jsonrpc": "2.0", "result": 1, "error": 0}')116# Request parsing hardness117def test_1_invalid_request():118 j = jsonrpc.JsonRpc10()119 _test_1_protocol_parse_base(j.loads_request)120 with pytest.raises(jsonrpc.RPCInvalidRPC): # missing method121 j.loads_request('{"id": 0}')122 with pytest.raises(jsonrpc.RPCInvalidRPC): # method must be str123 j.loads_request('{"id": 0, "method": -1}')124 with pytest.raises(jsonrpc.RPCInvalidRPC): # params is bad type125 j.loads_request('{"id": 0, "method": "foo", "params": -1}')126 with pytest.raises(jsonrpc.RPCInvalidRPC): # wrong number of fields127 j.loads_request('{"ba": 0, "method": "foo", "asdf": 1, "foobar": 2}')128 j.loads_request('{"id": 0, "method": "foo", "params": []}')129 j.loads_request('{"method": "foo", "params": []}')130# Request parsing hardness131def test_2_invalid_request():132 j = jsonrpc.JsonRpc20()133 _test_2_protocol_parse_base(j.loads_request)134 with pytest.raises(jsonrpc.RPCInvalidRPC): # missing method135 j.loads_request('{"id": 0, "jsonrpc": "2.0"}')136 with pytest.raises(jsonrpc.RPCInvalidRPC): # method must be str137 j.loads_request('{"id": 0, "jsonrpc": "2.0", "method": 1}')138 with pytest.raises(jsonrpc.RPCInvalidRPC): # params is bad type139 j.loads_request('{"id": 0, "jsonrpc": "2.0", "method": "foo", "params": -1}')140 with pytest.raises(jsonrpc.RPCInvalidRPC): # wrong number of fields141 j.loads_request('{"id": 0, "jsonrpc": "2.0", "method": "foo", "asdf": 1, "foobar": 2}')142 j.loads_request('{"id": 0, "jsonrpc": "2.0", "method": "foo", "params": []}')143 j.loads_request('{"jsonrpc": "2.0", "method": "foo", "params": []}')144def test_1_dumps_reqest():145 j = jsonrpc.JsonRpc20()146 with pytest.raises(TypeError):147 j.dumps_request(-1)148 with pytest.raises(TypeError):149 j.dumps_request("foo", params=-1)150 j.dumps_request("foo")151def test_2_dumps_reqest():152 j = jsonrpc.JsonRpc20()153 with pytest.raises(TypeError):154 j.dumps_request(-1)155 with pytest.raises(TypeError):156 j.dumps_request("foo", params=-1)157 j.dumps_request("foo", params=[])158 j.dumps_request("foo")159# Misc stuff160def test_logging(tmpdir):161 msg = "test log message"162 jsonrpc.log_dummy(msg)163 jsonrpc.log_stdout(msg)164 logpath = os.path.join(tmpdir, "test.log")165 logger = jsonrpc.log_file(logpath)166 logger(msg)167 assert os.path.exists(logpath)168 logpath = os.path.join(tmpdir, "test2.log")169 logger2 = jsonrpc.log_filedate(os.path.join(tmpdir, "test2.log"))170 logger2(msg)...

Full Screen

Full Screen

test_json.py

Source:test_json.py Github

copy

Full Screen

1"""2 Copyright (c) 2007 Jan-Klaas Kollhof3 This file is part of jsonrpc.4 jsonrpc is free software; you can redistribute it and/or modify5 it under the terms of the GNU Lesser General Public License as published by6 the Free Software Foundation; either version 2.1 of the License, or7 (at your option) any later version.8 This software is distributed in the hope that it will be useful,9 but WITHOUT ANY WARRANTY; without even the implied warranty of10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11 GNU Lesser General Public License for more details.12 You should have received a copy of the GNU Lesser General Public License13 along with this software; if not, write to the Free Software14 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA15"""16import unittest17import jsonrpc18from types import *19class TestDumps(unittest.TestCase):20 def setUp(self):21 pass22 def tearDown(self):23 pass24 25 def assertJSON(self, json, expectedJSON):26 self.assert_(type(json) is UnicodeType)27 self.assertEqual(json, expectedJSON)28 29 def test_Number(self):30 json = jsonrpc.dumps(1)31 self.assertJSON(json, u'1')32 33 json = jsonrpc.dumps(0xffffffffffffffffffffffff)34 self.assertJSON(json, u'79228162514264337593543950335')35 def test_None(self):36 json = jsonrpc.dumps(None)37 self.assertJSON(json, u'null')38 39 def test_Boolean(self):40 json = jsonrpc.dumps(False)41 self.assertJSON(json, u'false')42 json = jsonrpc.dumps(True)43 self.assertJSON(json, u'true')44 def test_Float(self):45 json = jsonrpc.dumps(1.2345)46 self.assertJSON(json, u'1.2345')47 json =jsonrpc.dumps(1.2345e67)48 self.assertJSON(json, u'1.2345e+67')49 json =jsonrpc.dumps(1.2345e-67)50 self.assertJSON(json, u'1.2345e-67')51 def test_String(self):52 json = jsonrpc.dumps('foobar')53 self.assertJSON(json, u'"foobar"')54 json = jsonrpc.dumps('foobar')55 self.assertJSON(json, u'"foobar"')56 def test_StringEscapedChars(self):57 json = jsonrpc.dumps('\n \f \t \b \r \\ " /')58 self.assertJSON(json, u'"\\n \\f \\t \\b \\r \\\\ \\" \\/"')59 def test_StringEscapedUnicodeChars(self):60 json = jsonrpc.dumps(u'\0 \x19 \x20\u0130')61 self.assertJSON(json, u'"\\u0000 \\u0019 \u0130"')62 def test_Array(self):63 json = jsonrpc.dumps([1, 2.3e45, 'foobar'])64 self.assertJSON(json, u'[1,2.3e+45,"foobar"]')65 def test_Dictionary(self):66 json = jsonrpc.dumps({'foobar':'spam', 'a':[1,2,3]})67 self.assertJSON(json, u'{"a":[1,2,3],"foobar":"spam"}')68 def test_FailOther(self):69 self.failUnlessRaises(jsonrpc.JSONEncodeException, lambda:jsonrpc.dumps(self))70 71 72class TestLoads(unittest.TestCase):73 def setUp(self):74 pass75 def tearDown(self):76 pass77 def test_String(self):78 json = jsonrpc.dumps("foobar")79 obj = jsonrpc.loads(json)80 self.assertEquals(obj, u"foobar")81 82 def test_StringEscapedChars(self):83 json = '"\\n \\t \\r \\b \\f \\\\ \\/ /"'84 obj = jsonrpc.loads(json)85 self.assertEquals(obj, u'\n \t \r \b \f \\ / /')86 87 def test_StringEscapedUnicodeChars(self):88 json = jsonrpc.dumps(u'\u0000 \u0019')89 obj = jsonrpc.loads(json)90 self.assertEquals(obj, u'\0 \x19')91 92 def test_Array(self):93 json = jsonrpc.dumps(['1', ['2','3']])94 obj = jsonrpc.loads(json)95 self.assertEquals(obj, ['1', ['2','3']])96 def test_Dictionary(self):97 json = jsonrpc.dumps({'foobar':'spam', 'nested':{'a':'b'}})98 obj = jsonrpc.loads(json)99 self.assertEquals(obj, {'foobar':'spam', 'nested':{'a':'b'}})100 def test_Int(self):101 json = jsonrpc.dumps(1234)102 obj = jsonrpc.loads(json)103 self.assertEquals(obj, 1234)104 def test_NegativeInt(self):105 json = jsonrpc.dumps(-1234)106 obj = jsonrpc.loads(json)107 self.assertEquals(obj, -1234)108 def test_NumberAtEndOfArray(self):109 json = jsonrpc.dumps([-1234])110 obj = jsonrpc.loads(json)111 self.assertEquals(obj, [-1234])112 def test_StrAtEndOfArray(self):113 json = jsonrpc.dumps(['foobar'])114 obj = jsonrpc.loads(json)115 self.assertEquals(obj, ['foobar'])116 117 def test_Float(self):118 json = jsonrpc.dumps(1234.567)119 obj = jsonrpc.loads(json)120 self.assertEquals(obj, 1234.567)121 def test_Exponential(self):122 json = jsonrpc.dumps(1234.567e89)123 obj = jsonrpc.loads(json)124 self.assertEquals(obj, 1234.567e89)125 def test_True(self):126 json = jsonrpc.dumps(True)127 obj = jsonrpc.loads(json)128 self.assertEquals(obj, True)129 def test_False(self):130 json = jsonrpc.dumps(False)131 obj = jsonrpc.loads(json)132 self.assertEquals(obj, False)133 def test_None(self):134 json = jsonrpc.dumps(None)135 obj = jsonrpc.loads(json)136 self.assertEquals(obj, None)137 def test_NestedDictAllTypes(self):138 json = jsonrpc.dumps({'s':'foobar', 'int':1234, 'float':1234.567, 'exp':1234.56e78,139 'negInt':-1234, 'None':None,'True':True, 'False':False,140 'list':[1,2,4,{}], 'dict':{'a':'b'}})141 obj = jsonrpc.loads(json)142 self.assertEquals(obj, {'s':'foobar', 'int':1234, 'float':1234.567, 'exp':1234.56e78,143 'negInt':-1234, 'None':None,'True':True, 'False':False,...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run uiautomator automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful