def test_async_exception(self): def broken(): raise IOError("Failed") with start_stop_one() as handler: r = handler.async_result() w = handler.spawn(utils.wrap(r)(broken)) w.join() assert r.successful() is False with pytest.raises(IOError): r.get()
def test_async_exception(self): @raises(IOError) def check_exc(r): r.get() def broken(): raise IOError("Failed") with start_stop_one() as handler: r = handler.async_result() w = handler.spawn(utils.wrap(r)(broken)) w.join() self.assertFalse(r.successful()) check_exc(r)
def test_async_ok(self): captures = [] def delayed(): captures.append(1) return 1 def after_delayed(handler): captures.append(handler) with start_stop_one() as handler: r = handler.async_result() r.rawlink(after_delayed) w = handler.spawn(utils.wrap(r)(delayed)) w.join() assert len(captures) == 2 assert captures[0] == 1 assert r.get() == 1
def test_async_ok(self): captures = [] def delayed(): captures.append(1) return 1 def after_delayed(handler): captures.append(handler) with start_stop_one() as handler: r = handler.async_result() r.rawlink(after_delayed) w = handler.spawn(utils.wrap(r)(delayed)) w.join() self.assertEqual(2, len(captures)) self.assertEqual(1, captures[0]) self.assertEqual(1, r.get())