~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 02:35:29 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:302
Updated test framework so that student's code is passed in as a string.

Show diffs side-by-side

added added

removed removed

Lines of Context:
363
363
        """ Get the name of the test case """
364
364
        return self._name
365
365
 
366
 
    def run(self, solution, attempt_file):
 
366
    def run(self, solution, attempt_code):
367
367
        """ Run the solution and the attempt with the inputs specified for this test case.
368
368
        Then pass the outputs to each test part and collate the results.
369
369
        """
387
387
        # Run student attempt
388
388
        try:
389
389
            global_space_copy = copy.deepcopy(self._global_space)
390
 
            attempt_data = self._execfile(attempt_file, global_space_copy)
 
390
            attempt_data = self._execstring(attempt_code, global_space_copy)
391
391
            
392
392
            # if we are just testing a function
393
393
            if not self._function == None:
521
521
        self._tests.append(test_case)
522
522
        test_case.validate_functions(self._include_space)
523
523
 
524
 
    def run_tests(self, attempt_file):
 
524
    def run_tests(self, attempt_code):
525
525
        " Run all test cases and collate the results "
526
526
        
527
527
        problem_dict = {}
529
529
        
530
530
        test_case_results = []
531
531
        for test in self._tests:
532
 
            result_dict = test.run(self._solution, attempt_file)
 
532
            result_dict = test.run(self._solution, attempt_code)
533
533
            if 'exception' in result_dict and result_dict['exception']['critical']:
534
534
                # critical error occured, running more cases is useless
535
535
                # FunctionNotFound, Syntax, Indentation