2
from parse_tute import *
4
def print_results((name, results)):
5
""" Print the output of a testsuite nicely """
7
for (case_name, test_results) in results:
8
print "Case: " + case_name
9
for test_result in test_results:
10
print " " + test_result
13
problem_suite = parse_tutorial_file('all_input_text.xml')
14
print_results(problem_suite.run_tests("all_input.py"))
16
problem_suite = parse_tutorial_file('fib_text.xml')
17
print_results(problem_suite.run_tests("fib.py"))
3
sys.path.append('../../www/apps/tutorialservice/test/')
5
from parse_exercise import *
7
def print_results(problem):
8
print "Problem: %s" %problem['name']
9
if 'critical_error' in problem:
10
error = problem['critical_error']
11
print "Critical error: %s - %s" %(error['name'], error['detail'])
13
for case in problem['cases']:
14
print "Case: %s" %case['name']
15
if 'exception' in case:
16
error = case['exception']
17
print "Exception %s - %s" %(error['name'], error['detail'])
19
for part in case['parts']:
21
print " Passed: %s" %part['description']
23
print " Failed: %s -- %s" %(part['description'],part['error_message'])
26
problem_suite = parse_exercise_file('filesum_text.xml')
27
print_results(problem_suite.run_tests(file("filesum.py").read()))
29
problem_suite = parse_exercise_file('hello_text.xml')
30
print_results(problem_suite.run_tests(file("hello.py").read()))
32
problem_suite = parse_exercise_file('all_input_text.xml')
33
print_results(problem_suite.run_tests(file("all_input.py").read()))
35
problem_suite = parse_exercise_file('fib_text.xml')
36
print_results(problem_suite.run_tests(file("fib.py").read()))