Skip to content

Commit 3aeb4a8

Browse files
committed
Strip leading and trailing spaces before comparing outputs
1 parent f192b1d commit 3aeb4a8

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

ACedIt/util.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,13 @@ def run_solution(problem):
216216
elif status == 0:
217217

218218
with open('temp_output' + str(i), 'r') as temp_handler, open(os.path.join(testcases_path, 'Output' + str(i)), 'r') as out_handler:
219-
expected_output = out_handler.read().strip()
220-
user_output = temp_handler.read().strip()
219+
expected_output = out_handler.read().strip().split('\n')
220+
user_output = temp_handler.read().strip().split('\n')
221+
222+
expected_output = '\n'.join(
223+
[line.strip() for line in expected_output])
224+
user_output = '\n'.join(
225+
[line.strip() for line in user_output])
221226

222227
expected_outputs += [expected_output]
223228
user_outputs += [user_output]
@@ -254,8 +259,13 @@ def run_solution(problem):
254259
elif status == 0:
255260

256261
with open('temp_output' + str(i), 'r') as temp_handler, open(os.path.join(testcases_path, 'Output' + str(i)), 'r') as out_handler:
257-
expected_output = out_handler.read().strip()
258-
user_output = temp_handler.read().strip()
262+
expected_output = out_handler.read().strip().split('\n')
263+
user_output = temp_handler.read().strip().split('\n')
264+
265+
expected_output = '\n'.join(
266+
[line.strip() for line in expected_output])
267+
user_output = '\n'.join(
268+
[line.strip() for line in user_output])
259269

260270
expected_outputs += [expected_output]
261271
user_outputs += [user_output]

0 commit comments

Comments
 (0)