def test_update(): cj = CCJson() cj['name'] = 'chen' d = {'a': 21, 'name': 'CHEN'} cj.update(d) if not (cj['a'] == 21 and cj['name'] == 'CHEN'): err('json object update failed') cj = CCJson() cj.append(1) cj.append(2) d = {0:11, 1:22} cj.update(d) if not (cj[0] == 11 and cj[1] == 22): err('json array update failed') d[4] = 44 try: cj.update(d) except IndexError: pass else: err('json array update: index error') print 'test CCJson update() passed'