Example #1
0
    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
Example #2
0
    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)
Example #3
0
 def _process_chain(self, methodname, obj, *args):
     return process_chain(self.methods[methodname], obj, *args)
Example #4
0
 def _process_chain(self, methodname: str, obj, *args) -> Deferred:
     return process_chain(self.methods[methodname], obj, *args)
Example #5
0
 def _process_chain(self, methodname, obj, *args):
     return process_chain(self.methods[methodname], obj, *args)
Example #6
0
    def process_hook(self, *args):

        return process_chain(self.methods["process_hook"], None, *args)
Example #7
0
 def _process_chain(self, methodname: str, obj, *args) -> Deferred:
     methods = cast(Iterable[Callable], self.methods[methodname])
     return process_chain(methods, obj, *args)
Example #8
0
 def _process_chain(self, methodname, obj, *args):
     return process_chain(
         self.methods[methodname], obj, *args
     )  # 这里的process_chain 实际上就是将self.methods里所有的callback添加到 一个deferred对象上 然后返回这个对象 参数是这个obj 和*args