def __or__(self, dest): #{{{ if isinstance(dest, cmdpipe): raise InvalidDestinationError("Cannot send data to an already established command pipe") selfcall = callcallable.__call__ qself = q(self, weak=False) p1 = q(callcallable(selfcall, qself), weak=False) return cmdpipe(p1, q(dest, weak=False))
def testCall(self): # {{{ """Call callcallable""" def testme(*args, **kwargs): # {{{ return len(args), len(kwargs) # End def #}}} a = callcallable(testme, 1, 2, q(testme), testme=q(testme), blue=1) self.assertEqual(a(), (3, 2))
def testArgsTransform(self): # {{{ """All args and keyword args are transformed into callobj objects""" def testme(*args, **kwargs): # {{{ return len(args), len(kwargs) # End def #}}} a = callcallable(testme, 1, 2, q(testme), testme=q(testme), blue=1) self.assertEqual(len(a._args), 3) self.assertEqual(len(a._kwargs), 2) for arg in a._args: self.assertTrue(isinstance(arg, callobj)) for k, v in a._kwargs.iteritems(): self.assertTrue(isinstance(v, callobj)) self.assertTrue(k in ("testme", "blue"))
def testSetInternalVars(self): # {{{ """Internal vars get set""" a = callcallable(int) self.assertEqual(getattr(a, "_args"), tuple()) self.assertEqual(getattr(a, "_kwargs"), dict()) self.assertEqual(getattr(a, "_callable"), int)