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_set_exception_once_only(): future = Future() future.set_exception(ValueError('wah wah')) with pytest.raises(RuntimeError): future.set_exception(TypeError('other wah wah'))