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

« back to all changes in this revision

Viewing changes to test/test_framework/tests.py

  • Committer: David Coles
  • Date: 2010-07-17 11:32:50 UTC
  • Revision ID: coles.david@gmail.com-20100717113250-vi18n50bcjmfmzrt
Show warning for CGI header field-names which contain restricted characters.

Forbidden characters are the separators defined by RFC3875. This is mainly to 
fix an issue where printing a dictionary (with no CGI headers) could be 
assumed to be a CGI header with no warnings.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
import sys
 
3
sys.path.append('../../www/apps/tutorialservice/test/')
 
4
 
 
5
from parse_exercise import *
 
6
 
 
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'])
 
12
    else:
 
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'])
 
18
            else:
 
19
                for part in case['parts']:
 
20
                    if part['passed']:
 
21
                        print "  Passed: %s" %part['description']
 
22
                    else:
 
23
                        print "  Failed: %s -- %s" %(part['description'],part['error_message'])
 
24
    print
 
25
    
 
26
problem_suite = parse_exercise_file('filesum_text.xml')
 
27
print_results(problem_suite.run_tests(file("filesum.py").read()))
 
28
 
 
29
problem_suite = parse_exercise_file('hello_text.xml')
 
30
print_results(problem_suite.run_tests(file("hello.py").read()))
 
31
 
 
32
problem_suite = parse_exercise_file('all_input_text.xml')
 
33
print_results(problem_suite.run_tests(file("all_input.py").read()))
 
34
 
 
35
problem_suite = parse_exercise_file('fib_text.xml')
 
36
print_results(problem_suite.run_tests(file("fib.py").read()))