~azzar1/unity/add-show-desktop-key

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import sys
sys.path.append('../../www/apps/tutorialservice/test/')

from parse_exercise import *

def print_results(problem):
    print "Problem: %s" %problem['name']
    if 'critical_error' in problem:
        error = problem['critical_error']
        print "Critical error: %s - %s" %(error['name'], error['detail'])
    else:
        for case in problem['cases']:
            print "Case: %s" %case['name']
            if 'exception' in case:
                error = case['exception']
                print "Exception %s - %s" %(error['name'], error['detail'])
            else:
                for part in case['parts']:
                    if part['passed']:
                        print "  Passed: %s" %part['description']
                    else:
                        print "  Failed: %s -- %s" %(part['description'],part['error_message'])
    print
    
problem_suite = parse_exercise_file('filesum_text.xml')
print_results(problem_suite.run_tests(file("filesum.py").read()))

problem_suite = parse_exercise_file('hello_text.xml')
print_results(problem_suite.run_tests(file("hello.py").read()))

problem_suite = parse_exercise_file('all_input_text.xml')
print_results(problem_suite.run_tests(file("all_input.py").read()))

problem_suite = parse_exercise_file('fib_text.xml')
print_results(problem_suite.run_tests(file("fib.py").read()))