284
by stevenbird
recovered tests.py from svn revision 280 and put in test.py |
1 |
import sys |
2 |
sys.path.append('../../www/apps/tutorialservice/test/') |
|
357
by stevenbird
fixed syntax error |
3 |
|
284
by stevenbird
recovered tests.py from svn revision 280 and put in test.py |
4 |
from parse_exercise import * |
513
by stevenbird
test/test_framework/*, exercises/sample/* |
5 |
|
284
by stevenbird
recovered tests.py from svn revision 280 and put in test.py |
6 |
def print_results(problem): |
290
by dilshan_a
Updated test.py so it works with the new output form test framework. |
7 |
print "Problem: %s" %problem['name'] |
8 |
if 'critical_error' in problem: |
|
9 |
error = problem['critical_error'] |
|
10 |
print "Critical error: %s - %s" %(error['name'], error['detail']) |
|
11 |
else: |
|
12 |
for case in problem['cases']: |
|
13 |
print "Case: %s" %case['name'] |
|
14 |
if 'exception' in case: |
|
15 |
error = case['exception'] |
|
16 |
print "Exception %s - %s" %(error['name'], error['detail']) |
|
17 |
else: |
|
18 |
for part in case['parts']: |
|
19 |
if part['passed']: |
|
20 |
print " Passed: %s" %part['description'] |
|
21 |
else: |
|
22 |
print " Failed: %s -- %s" %(part['description'],part['error_message']) |
|
23 |
print
|
|
24 |
||
284
by stevenbird
recovered tests.py from svn revision 280 and put in test.py |
25 |
for i in range(1, len(sys.argv)): |
26 |
basename = sys.argv[i] |
|
27 |
xmlfile = basename + '_text.xml' |
|
28 |
pyfile = basename + '.py' |
|
29 |
||
30 |
print "Testing:", basename |
|
31 |
problem_suite = parse_exercise_file(xmlfile) |
|
513
by stevenbird
test/test_framework/*, exercises/sample/* |
32 |
print_results(problem_suite.run_tests(file(pyfile).read())) |
302
by dilshan_a
Updated test framework so that student's code is passed in as a string. |
33 |