a1 = JSONParser() a2 = JSONParser() a3 = JSONParser() total = 0 expect = 0 errors = [] for s, score in chain(json_ok, json_ex): expect += score try: dst = json.loads(s) except Exception: dst = Exception try: a1.loads(s) d1 = a1.dump_dict() except Exception as ex: d1 = ex if (dst is Exception and isinstance(d1, Exception)) or (dst == d1): total += score elif isinstance(d1, Exception): errors.append([s, 'ret ex:' + str(d1)]) else: errors.append([s, json.dumps(d1)]) tmp_output_file = 'tmp_output_file.txt' for s, score in json_ok2: expect += score try: