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()
def test_result_with_error(): future = Future() future.set_exception(RuntimeError('Something really bad happened.')) with pytest.raises(RuntimeError): future.result()
def test_result_no_error(): future = Future() future.set_result('42') assert future.result() == '42'