def testFailAndStop(self): def foo(x): lc.stop() raise TestException(x) lc = task.LoopingCall(foo, "bar") return self.assertFailure(lc.start(0.1), TestException)