def test_process_chain(self): x = yield process_chain([cb1, cb2, cb3], 'res', 'v1', 'v2') self.assertEqual(x, "(cb3 (cb2 (cb1 res v1 v2) v1 v2) v1 v2)") gotexc = False try: yield process_chain([cb1, cb_fail, cb3], 'res', 'v1', 'v2') except TypeError, e: gotexc = True
def test_process_chain(self): x = yield process_chain([cb1, cb2, cb3], "res", "v1", "v2") self.assertEqual(x, "(cb3 (cb2 (cb1 res v1 v2) v1 v2) v1 v2)") gotexc = False try: yield process_chain([cb1, cb_fail, cb3], "res", "v1", "v2") except TypeError as e: gotexc = True self.failUnless(gotexc)
def _process_chain(self, methodname, obj, *args): return process_chain(self.methods[methodname], obj, *args)
def _process_chain(self, methodname: str, obj, *args) -> Deferred: return process_chain(self.methods[methodname], obj, *args)
def process_hook(self, *args): return process_chain(self.methods["process_hook"], None, *args)
def _process_chain(self, methodname: str, obj, *args) -> Deferred: methods = cast(Iterable[Callable], self.methods[methodname]) return process_chain(methods, obj, *args)
def _process_chain(self, methodname, obj, *args): return process_chain( self.methods[methodname], obj, *args ) # 这里的process_chain 实际上就是将self.methods里所有的callback添加到 一个deferred对象上 然后返回这个对象 参数是这个obj 和*args