Exemplo n.º 1
0
 def test_set_exception(self):
     f = Future(self.task)
     e = ValueError("test Error")
     f.set_exception(e)
     self.assertTrue(f.done())
     self.assertRaises(ValueError, f.result, 0)
     self.assertEqual(f.exception(), e)
Exemplo n.º 2
0
 def test_exception(self):
     # timeout due to no response arriving
     f0 = Future(self.task)
     f1 = Future(self.task)
     self.task._futures = {0: f0, 1: f1}
     self.assertRaises(queue.Empty, f0.exception, 0)
     # return after waiting for response object
     resp0 = Return(0, None, None)
     resp0.set_value('testVal')
     resp1 = Error(1, None, None)
     resp1.set_message('test Error')
     self.task.q.put(resp0)
     self.task.q.put(resp1)
     with self.assertRaises(ValueError) as cm:
         f1.exception()
     self.assertEqual(str(cm.exception), 'test Error')
Exemplo n.º 3
0
 def test_exception(self):
     # timeout due to no response arriving
     f0 = Future(self.task)
     f1 = Future(self.task)
     self.task._futures = {0: f0, 1: f1}
     self.assertRaises(queue.Empty, f0.exception, 0)
     # return after waiting for response object
     resp0 = Return(0, None, None)
     resp0.set_value('testVal')
     resp1 = Error(1, None, None)
     resp1.set_message('test Error')
     self.task.q.put(resp0)
     self.task.q.put(resp1)
     with self.assertRaises(ResponseError) as cm:
         f1.exception()
     self.assertEqual(str(cm.exception), 'test Error')
Exemplo n.º 4
0
 def test_set_exception(self):
     f = Future(self.task)
     e = ValueError("test Error")
     f.set_exception(e)
     self.assertTrue(f.done())
     self.assertRaises(ValueError, f.result, 0)
     self.assertEqual(f.exception(), e)
Exemplo n.º 5
0
 def test_set_exception(self):
     f = Future(self.context)
     e = ValueError("test Error")
     f.set_exception(e)
     assert f.done()
     with self.assertRaises(ValueError):
         f.result(timeout=0)
     assert f.exception() == e
Exemplo n.º 6
0
    def test_exception(self):
        f = Future(self.context)

        def wait_all_futures(fs, timeout):
            fs[0].set_exception(MyError())

        self.context.wait_all_futures.side_effect = wait_all_futures

        with self.assertRaises(MyError):
            f.result()

        self.context.wait_all_futures.assert_called_once_with([f], None)
        self.context.wait_all_futures.reset_mock()
        self.assertIsInstance(f.exception(), MyError)
        self.context.wait_all_futures.assert_not_called()
Exemplo n.º 7
0
 def test_set_exception(self):
     f = Future(self.task)
     f.set_exception("test Error")
     self.assertTrue(f.done())
     self.assertRaises(RemoteError, f.result, 0)
     self.assertEqual(f.exception(),'test Error')
Exemplo n.º 8
0
 def test_set_exception(self):
     f = Future(self.task)
     f.set_exception("test Error")
     self.assertTrue(f.done())
     self.assertRaises(RemoteError, f.result, 0)
     self.assertEqual(f.exception(), 'test Error')