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

« back to all changes in this revision

Viewing changes to test/test_framework/tests.py

  • Committer: stevenbird
  • Date: 2008-01-24 04:23:25 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:282
* changed spelling of varible to variable
* example hello world test cases

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 
5
5
from parse_tute import *
6
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_tutorial_file('hello_text.xml')
27
 
print_results(problem_suite.run_tests("hello.py"))
28
 
 
29
 
problem_suite = parse_tutorial_file('all_input_text.xml')
30
 
print_results(problem_suite.run_tests("all_input.py"))
31
 
 
32
 
problem_suite = parse_tutorial_file('fib_text.xml')
33
 
print_results(problem_suite.run_tests("fib.py"))
 
7
def print_results((name, results)):
 
8
    """ Print the output of a testsuite nicely """
 
9
    print name
 
10
    for (case_name, test_results) in results:
 
11
        print "Case: " + case_name
 
12
        for test_result in test_results:
 
13
            print "  " + test_result
 
14
    print 
 
15
 
 
16
for i in range(1, len(sys.argv)):
 
17
    basename = sys.argv[i]
 
18
    xmlfile = basename + '_text.xml'
 
19
    pyfile = basename + '.py'
 
20
 
 
21
    print "Testing:", basename
 
22
    problem_suite = parse_tutorial_file(xmlfile)
 
23
    print_results(problem_suite.run_tests(pyfile))