-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-tests.py
More file actions
23 lines (19 loc) · 750 Bytes
/
run-tests.py
File metadata and controls
23 lines (19 loc) · 750 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from subprocess import check_output
import os
import sys
if len(sys.argv) >= 2:
test_file = sys.argv[1]
else:
test_file = 'problem.py'
for i in range(len(os.listdir('test-cases'))/2):
cmd = ['python', test_file]
# cmd = 'sbcl --script problem.lisp'.split(' ')
# cmd = 'python %s' % test_file
# cmd = cmd.split(' ')
output = check_output(cmd, stdin=open('test-cases/input0' + str(i) + '.txt')).strip('\n')
expected_output = open('test-cases/output0' + str(i) + '.txt').read()
try:
assert output == expected_output, 'Test case %d failed: Expected: %s Actual: %s' % (i, expected_output, output)
print 'Test case %d passed successfully!' % i
except AssertionError as e:
print e