1+ from __future__ import absolute_import
12from cyaron import IO
3+ from cyaron .utils import *
24from cyaron .consts import *
35from cyaron .graders import CYaRonGraders
46import subprocess
57import sys
6- import io
8+ from io import open
79
810
911class Compare :
@@ -20,12 +22,12 @@ def __compare_two(name, content, std, grader, **kwargs):
2022 if stop_on_incorrect and not result :
2123 if custom_dump_data :
2224 (dump_name , dump_lambda ) = custom_dump_data
23- with open (dump_name , "w" ) as f :
25+ with open (dump_name , "w" , newline = ' \n ' ) as f :
2426 f .write (dump_lambda ())
2527
26- with open ("std.out" , "w" ) as f :
28+ with open ("std.out" , "w" , newline = ' \n ' ) as f :
2729 f .write (std )
28- with open ("%s.out" % name , "w" ) as f :
30+ with open ("%s.out" % name , "w" , newline = ' \n ' ) as f :
2931 f .write (content )
3032
3133 print ("Relevant files dumped." )
@@ -40,7 +42,7 @@ def __process_file(file):
4042 file .output_file .seek (0 )
4143 return file .output_filename , file .output_file .read ()
4244 else :
43- with open (file , "r" ) as f :
45+ with open (file , "r" , newline = ' \n ' ) as f :
4446 return file , f .read ()
4547
4648 @staticmethod
@@ -77,7 +79,7 @@ def program(*args, **kwargs):
7779 raise Exception ("You must specify a std or a std_program." )
7880 else :
7981 if "std_program" in kwargs :
80- std = subprocess .check_output (kwargs ['std_program' ], shell = True , stdin = input .input_file ). decode ( 'ascii' )
82+ std = make_unicode ( subprocess .check_output (kwargs ['std_program' ], shell = True , stdin = input .input_file , universal_newlines = True ) )
8183 else :
8284 (_ , std ) = Compare .__process_file (kwargs ["std" ])
8385
@@ -86,7 +88,7 @@ def program(*args, **kwargs):
8688
8789 for program_name in args :
8890 input .input_file .seek (0 )
89- content = subprocess .check_output (program_name , shell = True , stdin = input .input_file )
91+ content = make_unicode ( subprocess .check_output (program_name , shell = True , stdin = input .input_file , universal_newlines = True ) )
9092
9193 input .input_file .seek (0 )
9294 Compare .__compare_two (program_name , content , std , grader ,
0 commit comments