Beispiel #1
0
except Exception as ex:
    errors.append(['get_item', "ex:" + str(ex)])

try:
    expect += 3
    del a4["a"]
    if "a" not in a4:
        total += 3
except Exception as ex:
    errors.append(['del', "ex:" + str(ex)])

# test update()
try:
    expect += 2
    src_dict = {"a": [1, 2]}
    a4.update(src_dict)
    assert a4["a"] == [1, 2] and a4["a"] is not src_dict["a"]
    total += 2
except Exception as ex:
    errors.append(['update', "ex:" + str(ex)])

# test time
import time

s = json.dumps({"a": 123456, "b": [{"a": "test", "b": True}], "c": "1" * 100})

start = time.time()
for i in range(1000):
    json.loads(s)
elapsed1 = time.time() - start