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

« back to all changes in this revision

Viewing changes to ivle/webapp/tutorial/test/TestFramework.py

  • Committer: William Grant
  • Date: 2009-12-15 04:52:55 UTC
  • Revision ID: me@williamgrant.id.au-20091215045255-qsfeu9q2m4i5u7yy
Add exact match support to the TestFramework backend.

Show diffs side-by-side

added added

removed removed

Lines of Context:
190
190
        it will be evaluated by a hack in _check_code.
191
191
        """
192
192
        
193
 
        if test_type not in ['norm', 'check']:
 
193
        if test_type not in ['norm', 'check', 'match']:
194
194
            raise TestCreationError("Invalid test type in %s" %self._desc)
195
195
        
196
196
        if function == '':
274
274
        """
275
275
        solution_output = str(solution_output)
276
276
        attempt_output = str(attempt_output)
277
 
            
278
 
        if test_type == 'norm':
 
277
 
 
278
        if test_type == 'match':
 
279
            return solution_output == attempt_output
 
280
        elif test_type == 'norm':
279
281
            return f(solution_output) == f(attempt_output)
280
282
        else:
281
283
            return f(solution_output, attempt_output)
288
290
        # an actual callable object.
289
291
        if type(f) in types.StringTypes:
290
292
            f = eval(str(f), include_space)
291
 
        if test_type == 'norm':
 
293
        if test_type == 'match':
 
294
            return solution == attempt
 
295
        elif test_type == 'norm':
292
296
            return f(solution) == f(attempt)
293
297
        else:
294
298
            return f(solution, attempt)