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

« back to all changes in this revision

Viewing changes to www/apps/tutorialservice/test/parse_exercise.py

  • Committer: dcoles
  • Date: 2008-08-19 06:44:05 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:1029
Tutorial Service: Ported the tutorial service to the console so that all 
student code should now be run inside the jail. This means that the code will 
also be contrained by trampoline's ulimits and will no longer need to run as 
the webserver (with all the badness that entails).

* TestFramework has been modifed to make eqvivalent calls to the console.
* Tutorial service now starts up a console for each attempt.
* Modifications to python-console script and console module to allow new calls 
needed.
* Added a FakeObject class to util to use to represent things that can not be 
pickled. (Ideally should be in the console module, but the console module can't 
be imported into the jail at the moment - relies on a full lib/conf/conf.py).  
Might be possible to make these fake objects able to call the console too?

Show diffs side-by-side

added added

removed removed

Lines of Context:
99
99
 
100
100
    return part
101
101
 
102
 
def getCaseData(caseNode):
 
102
def getCaseData(caseNode, console):
103
103
    """ Create a TestCase instance from test case xml data
104
104
    """
105
105
    
106
106
    case_name = caseNode.getAttribute('name')
107
107
    function = caseNode.getAttribute('function')
108
108
    if function == '': function = None
109
 
    case = TestCase(case_name, function)
 
109
    case = TestCase(console, case_name, function)
110
110
    
111
111
    for child in caseNode.childNodes:
112
112
        if child.nodeType != child.ELEMENT_NODE:
148
148
 
149
149
    return case
150
150
                
151
 
def parse_exercise_file(fileobj, exercise_num=1):
 
151
def parse_exercise_file(fileobj, console, exercise_num=1):
152
152
    """ Parse an xml exercise file and return a testsuite for that exercise """
153
153
    dom = parse(fileobj)
154
154
 
170
170
    if not exercise_name:
171
171
        raise ParseException('Exercise name not supplied')
172
172
 
173
 
    exercise_suite = TestSuite(exercise_name)
 
173
    exercise_suite = TestSuite(exercise_name, console)
174
174
 
175
175
    # get solution and include info
176
176
    for child in exercise.childNodes:
181
181
        elif child.tagName == 'include':
182
182
            exercise_suite.add_include_code(getTextData(child))
183
183
        elif child.tagName == 'case':
184
 
            exercise_suite.add_case(getCaseData(child))
 
184
            exercise_suite.add_case(getCaseData(child, console))
185
185
 
186
186
    return exercise_suite
187
187