def test_success(self): mte = MainThreadExecutor() future = mte.submit(self.success, 42) self.assertEquals(42, future.result()) future = mte.submit(self.success, ret=43) self.assertEquals(43, future.result())
def test_exception(self): mte = MainThreadExecutor() e = Exception('boom') future = mte.submit(self.exception, e) with self.assertRaises(Exception) as ctx: future.result() self.assertEquals(e, ctx.exception) future = mte.submit(self.exception, e=e) with self.assertRaises(Exception) as ctx: future.result() self.assertEquals(e, ctx.exception)