~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:13:44 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:305
Neated up execution of strings in TestCase.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
 
45
45
    def to_dict(self):
46
46
        return {'name': self._name,
47
 
                'detail': self._detail
 
47
                'detail': self._detail,
48
48
                'critical': False
49
49
                }
50
50
 
429
429
    def _execstring(self, string, global_space):
430
430
        """ Execute the given string in global_space, and return the outputs. """
431
431
        self._initialise_global_space(global_space)
432
 
        # _run_function handles tuples in a special way
433
 
        data = self._run_function((string, global_space))
 
432
        
 
433
        def f():
 
434
            exec string in global_space
 
435
            
 
436
        data = self._run_function(f)
434
437
        return data
435
438
 
436
439
    def _initialise_global_space(self, global_space):
458
461
        exception_name = None
459
462
        
460
463
        try:
461
 
            if type(function) == tuple:
462
 
                # very hackish... exec can't be put into a lambda function!
463
 
                # or even with eval
464
 
                exec(function[0], function[1])
465
 
            else:
466
 
                result = function()
 
464
            result = function()
467
465
        except:
468
466
            sys.stdout, sys.stdin, sys.stderr = sys_stdout, sys_stdin, sys_stderr
469
467
            exception_name = sys.exc_info()[0].__name__