@@ -15,9 +15,9 @@ def __init__(self, name, mismatch):
1515 super (CompareMismatch , self ).__init__ (name , mismatch )
1616 self .name = name
1717 self .mismatch = mismatch
18-
18+
1919 def __str__ (self ):
20- return self . mismatch . __str__ ( )
20+ return 'In program: \' {} \' . {}' . format ( self . name , self . mismatch )
2121
2222
2323class Compare :
@@ -114,7 +114,10 @@ def program(cls, *programs, **kwargs):
114114
115115 if std_program is not None :
116116 def get_std ():
117- return make_unicode (subprocess .check_output (std_program , shell = (not list_like (std_program )), stdin = input .input_file , universal_newlines = True ))
117+ with open (os .dup (input .input_file .fileno ()), 'r' , newline = '\n ' ) as input_file :
118+ content = make_unicode (subprocess .check_output (std_program , shell = (not list_like (std_program )), stdin = input .input_file , universal_newlines = True ))
119+ input_file .seek (0 )
120+ return content
118121 if job_pool is not None :
119122 std = job_pool .submit (get_std ).result ()
120123 else :
@@ -138,6 +141,7 @@ def do(program_name):
138141 content = make_unicode (subprocess .check_output (program_name , shell = (not list_like (program_name )), stdin = input_file , universal_newlines = True ))
139142 else :
140143 content = make_unicode (subprocess .check_output (program_name , shell = (not list_like (program_name )), stdin = input_file , universal_newlines = True , timeout = timeout ))
144+ input_file .seek (0 )
141145 cls .__compare_two (program_name , content , std , grader )
142146
143147 if job_pool is not None :
0 commit comments