def run(self, func, args, **kwargs): F = FunctionTask() serialized = F.serialize(func,args,**kwargs) try: task_instance = self.queue_task('task.FunctionTask.FunctionTask', \ {'s':serialized}) self.task_id = task_instance['instance_id'] except ControllerException, e: error = e.code
class cases(unittest.TestCase): def setUp(self): self.l = locals().copy() self.g = globals().copy() self.F = FunctionTask([self.l,self.g],globals()) def test_initial(self): """Testing Function dependency """ del globals()['mul'] self.F.serialize(foo,(2,)) def test_arguments_type(self): """ Arguments should be specified in tuples """ self.assertRaises(TypeError,self.F.serialize,(foo,[2,])) def test_argument(self): """ Testing type of argument in Arguments """ f = fun() self.assertRaises(TypeError,self.F.serialize,(my_exec,(f.double,3))) def test_function(self): """function type should not be class instance method """ f = fun() self.assertRaises(TypeError,self.F.serialize,(f.double,(2,))) def test_modules(self): """Testing Module dependency""" del globals()['math'] self.F.serialize(my_pow,(2,3)) def tearDown(self): del self.l del self.g del self.F
def setUp(self): self.l = locals().copy() self.g = globals().copy() self.F = FunctionTask([self.l,self.g],globals())