def test_set_func(self): c1 = Command('foo', 'my_adder', 'Target', t='t') self.failIf(c1.is_set()) c1.func = lambda x: x self.failUnless(c1.is_set())
def __call__(self, c1, c2): """ add c1 and c2 together to form a pipe command @return: a multiDriver instance """ if isinstance(c1, DataContainer): driver = RemoteDriver() if isinstance(c2, Command): driver.setSource(c1) driver.addCommand(c2) else: raise TypeError(self.ERRORMSG2) elif isinstance(c1, Command): if isinstance(c1.func, RemoteDriver): driver = c1.func else: driver = RemoteDriver() driver.addCommand(c1) if isinstance(c2, DataContainer): driver.setTarget(c2) elif isinstance(c2, Command): driver.addCommand(c2) elif c2 is None: pass else: raise TypeError(self.ERRORMSG1 % type(c2)) else: raise TypeError(self.ERRORMSG1 % type(c2)) com = Command("_multi_", self) com.func = driver return com
def testcopy(self): foo_tgt = Target('foo') bar_tgt = Target('bar') spam_src = Source('spam') c1 = Command('foo', None, foo_tgt, x=bar_tgt, src=spam_src) c2 = c1.copy() self.failUnlessEqual(c1, c2) self.failIfEqual(id(c1), id(c2)) func = lambda x: x c2.func = func self.failIfEqual(c1, c2) c1.func = func self.failUnlessEqual(c1, c2)