def filecomp_t(): global tda tda = {} # list of files to compare files = [ ("test_1.txt", "diff") ] # delete output files before running test filecomp.delete_output_files(files) # some data l = [{'a': 1, 'b': 2}, [1, 2]] # make the output file ( in directory out/ ) f = open("out/test_1.txt", "w") result = json.dump(l, f, indent=4, sort_keys=True, default=str) f.close() # file comparison tool filecomp.compare_files( # files to compare files, # name to use to construct okfile "okfile/" + os.path.basename(__file__) + ".test_1", # tda dict (to record name of okfile) tda )
def json_file(): global tda tda = {} # list of files to compare files = [ ("test_1.txt", "diff", {'rstrip': True}) ] # delete output files before running test filecomp.delete_output_files(files) # some data l = [{'a': 1, 'b': 2}, [1, 2]] # make the output file ( in directory out/ ) f = open("out/test_1.txt", "w") result = json.dump(l, f, indent=4, sort_keys=True, default=str) f.close() # file comparison tool filecomp.compare_files( # files to compare files, # name to use to construct okfile "okfile/" + os.path.basename(__file__) + ".test_1", # tda dict (to record name of okfile) tda )
print(("KEY", x)) del tinfo['start_time'] del tinfo['end_time'] del tinfo['key_id'] tinfo['location'] = tinfo['location'].split('pdkrun_test_data')[1] if 'tda__okfile' in tinfo: tinfo['tda__okfile'] = tinfo['tda__okfile'].split( 'pdkrun_test_data')[1] # bug: should drop the traceback part, but keep the exception at the # end tinfo['log'] = tinfo['log'].split('Traceback')[0] # to a file fname = test.replace('/', '#') fname = fname.replace('\\', '#') f = open("out/%s" % fname, "w") json.dump(d, f, indent=4, sort_keys=True, default=str) f.close() output = [(fname, 'diff')] filecomp.compare_files(output, (__file__, test), tda, tra) with pycode.test('no_dups'): if len(d) > 0: print("Extra results:") for x in d: print((json.dumps(x, indent=4, sort_keys=True, default=str)))