Exemplo n.º 1
0
def test_exception_with_error():
    future = Future()
    error = RuntimeError('Something really bad happened.')
    future.set_exception(error)

    # Make sure that the exception that is returned is the batch's error.
    # Also check the type to ensure the batch's error did not somehow
    # change internally.
    assert future.exception() is error
    assert isinstance(future.exception(), RuntimeError)
    with pytest.raises(RuntimeError):
        future.result()
Exemplo n.º 2
0
def test_exception_timeout():
    future = Future()
    with pytest.raises(exceptions.TimeoutError):
        future.exception(timeout=0.01)
Exemplo n.º 3
0
def test_exception_no_error():
    future = Future()
    future.set_result('12345')
    assert future.exception() is None