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

« back to all changes in this revision

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

  • Committer: David Coles
  • Date: 2010-02-24 11:12:04 UTC
  • mfrom: (1691.1.2 trunk2)
  • Revision ID: coles.david@gmail.com-20100224111204-mphy7kzp4t209cjw
Unbreak exception variable support for exercises

Show diffs side-by-side

added added

removed removed

Lines of Context:
394
394
            elif var.var_type == "arg":
395
395
                self.add_arg(var)
396
396
            elif var.var_type == "exception":
397
 
                # XXX: wgrant 2010-01-29 bug=514160: Need to restore
398
 
                # support for this.
399
 
                raise AssertionError("Exception variables unsupported.")
400
397
                self.add_exception(var)
401
398
        
402
399
        for test_case in suite.test_cases:
447
444
        except:
448
445
            raise TestCreationError("Invalid value for function argument: %s" %var.var_value)
449
446
 
450
 
    def add_exception(self, exception_name):
 
447
    def add_exception(self, var):
451
448
        self._allowed_exceptions.add(var.var_name)
452
449
        
453
450
    def add_part(self, test_part):
554
551
        if 'exception' in inspection:
555
552
            exception = inspection['exception']
556
553
            exception_name = type(exception).__name__
557
 
            raise(exception)
 
554
            if exception_name not in self._allowed_exceptions:
 
555
                raise(exception)
558
556
 
559
557
        return {'code': string,
560
558
                'result': None,
561
559
                'globals': self._console.globals(),
562
 
                'exception': exception_name, # Hmmm... odd? Is this right?
 
560
                'exception': exception_name,
563
561
                'stdout': self._console.stdout.read(),
564
562
                'stderr': self._console.stderr.read(),
565
563
                'modified_files': None}