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

« back to all changes in this revision

Viewing changes to test/test_framework/test.py

  • Committer: William Grant
  • Date: 2009-05-26 02:10:08 UTC
  • Revision ID: grantw@unimelb.edu.au-20090526021008-hnka598yacu5w6da
Always set isdir = False in the file browser template filling.

Previously we used os.path.isdir outside the jail, which was terribly
unreliable and prone to crashing. We should do it properly once we can get
server-side access to the jails.

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
for i in range(1, len(sys.argv)):
 
27
    basename = sys.argv[i]
 
28
    xmlfile = basename + '_text.xml'
 
29
    pyfile = basename + '.py'
 
30
 
 
31
    print "Testing:", basename
 
32
    problem_suite = parse_exercise_file(xmlfile)
 
33
    print_results(problem_suite.run_tests(file(pyfile).read()))