Changeset 995 for tester/tester.py
- Timestamp:
- 07/09/20 16:35:19 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tester/tester.py
r994 r995 89 89 else: 90 90 print("\r", globals.ANSI_SETRED + " FAIL\7" + globals.ANSI_RESET) 91 print(compare.result) 91 try: 92 print(compare.result) 93 except UnicodeEncodeError: 94 print(compare.result.encode("utf-8")) #only encode as utf8 when it is actually used, but this looks incorrect and perhaps should not be needed if the console supports utf8? 95 #sys.stdout.buffer.write(compare.result.encode("utf-8")) #prints nothing (on cygwin) 92 96 failed_result_filename = compare.list2_file + was_compared_to 93 97 if failed_result_filename == '': 94 98 failed_result_filename = '_test' 95 f = open(os.path.join(globals.THISDIR, failed_result_filename + '.Failed-output'), 'w' ) # files are easier to compare than stdout99 f = open(os.path.join(globals.THISDIR, failed_result_filename + '.Failed-output'), 'w', encoding='utf8') # files are easier to compare than stdout 96 100 print('\n'.join(jest)+'\n', end="", file=f) # not sure why one last empty line is always lost (or one too much is expected?), adding here... 97 f = open(os.path.join(globals.THISDIR, failed_result_filename + '.Failed-goal'), 'w' ) # files are easier to compare than stdout101 f = open(os.path.join(globals.THISDIR, failed_result_filename + '.Failed-goal'), 'w', encoding='utf8') # files are easier to compare than stdout 98 102 print('\n'.join(goal), end="", file=f) 99 103 return compare.equal … … 173 177 174 178 175 def print_exception( ):179 def print_exception(exc): 176 180 print("\n"+("-"*60),'begin exception') 181 print(exc) # some exceptions have an empty traceback, they only provide one-line exception name 177 182 traceback.print_exc() 178 183 print("-"*60,'end exception') … … 223 228 globals.init_colors(args) 224 229 225 fin = open(os.path.join(globals.THISDIR, args.file) )230 fin = open(os.path.join(globals.THISDIR, args.file), encoding='utf8') 226 231 reset_values() 227 232 exe_prog = "default" # no longer in reset_values (exe: persists across tests) … … 264 269 try: 265 270 contents = [] 266 with open(os.path.join(globals.FILESDIR, line[1]), 'r' ) as main_test_filename:271 with open(os.path.join(globals.FILESDIR, line[1]), 'r', encoding='utf8') as main_test_filename: 267 272 for line in main_test_filename: 268 273 contents.append(globals.stripEOL(line)) 269 274 ok = compare(contents, outfile, '_file') # +line[1] 270 275 except Exception as e: # could also 'raise' for some types of exceptions if we wanted 271 print_exception( )276 print_exception(e) 272 277 ok = 0 273 278 tests_failed += int(not ok) … … 279 284 ok = test(args, test_name, input_text, output_net, output_msg, exe_prog, exeargs) 280 285 except Exception as e: # could also 'raise' for some types of exceptions if we wanted 281 print_exception( )286 print_exception(e) 282 287 ok = 0 283 288 tests_failed += int(not ok)
Note: See TracChangeset
for help on using the changeset viewer.