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

« back to all changes in this revision

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

  • Committer: dilshan_a
  • Date: 2008-01-25 03:09:19 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:304
Added documentation of output of TestSuite.

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
    def to_dict(self):
46
46
        return {'name': self._name,
47
47
                'detail': self._detail
 
48
                'critical': False
48
49
                }
49
50
 
50
51
    def exc_info(self):
396
397
                attempt_data = self._run_function(lambda: global_space_copy[self._function](*self._list_args, **self._keyword_args))
397
398
        except:
398
399
            case_dict['exception'] = AttemptError(sys.exc_info()).to_dict()
 
400
            case_dict['passed'] = False
399
401
            return case_dict
400
402
        
401
403
        results = []
402
 
 
 
404
        passed = True
 
405
        
403
406
        # generate results
404
407
        for test_part in self._parts:
405
408
            result = test_part.run(solution_data, attempt_data)
408
411
            result_dict['passed']  = (result == '')
409
412
            if result_dict['passed'] == False:
410
413
                result_dict['error_message'] = result
 
414
                passed = False
411
415
                
412
416
            results.append(result_dict)
413
417
 
414
418
        case_dict['parts'] = results
 
419
        case_dict['passed'] = passed
415
420
 
416
421
        return case_dict
417
422
                
521
526
        self._tests.append(test_case)
522
527
        test_case.validate_functions(self._include_space)
523
528
 
524
 
    def run_tests(self, attempt_code):
 
529
    def run_tests(self, attempt_code, stop_on_fail=True):
525
530
        " Run all test cases and collate the results "
526
531
        
527
532
        problem_dict = {}
537
542
                return problem_dict
538
543
            
539
544
            test_case_results.append(result_dict)
 
545
            
 
546
            if not result_dict['passed'] and stop_on_fail:
 
547
                break
540
548
 
541
549
        problem_dict['cases'] = test_case_results
542
550
        return problem_dict