Make YAPF happy

pull/21455/head
Pau Freixes 5 years ago
parent 2a342b22a7
commit db54580f20
  1. 14
      src/python/grpcio_tests/tests_aio/unit/_test_server.py
  2. 6
      src/python/grpcio_tests/tests_aio/unit/channel_test.py
  3. 19
      src/python/grpcio_tests/tests_aio/unit/interceptor_test.py

@ -54,17 +54,17 @@ class _TestServiceServicer(test_pb2_grpc.TestServiceServicer):
async def start_test_server(): async def start_test_server():
server = aio.server(options=(('grpc.so_reuseport', 0),)) server = aio.server(options=(('grpc.so_reuseport', 0),))
servicer = _TestServiceServicer() servicer = _TestServiceServicer()
test_pb2_grpc.add_TestServiceServicer_to_server(servicer, test_pb2_grpc.add_TestServiceServicer_to_server(servicer, server)
server)
# Add programatically extra methods not provided by the proto file # Add programatically extra methods not provided by the proto file
# that are used during the tests # that are used during the tests
rpc_method_handlers = { rpc_method_handlers = {
'UnaryCallWithSleep': grpc.unary_unary_rpc_method_handler( 'UnaryCallWithSleep':
servicer.UnaryCallWithSleep, grpc.unary_unary_rpc_method_handler(
request_deserializer=messages_pb2.SimpleRequest.FromString, servicer.UnaryCallWithSleep,
response_serializer=messages_pb2.SimpleResponse.SerializeToString request_deserializer=messages_pb2.SimpleRequest.FromString,
) response_serializer=messages_pb2.SimpleResponse.
SerializeToString)
} }
extra_handler = grpc.method_handlers_generic_handler( extra_handler = grpc.method_handlers_generic_handler(
'grpc.testing.TestService', rpc_method_handlers) 'grpc.testing.TestService', rpc_method_handlers)

@ -70,7 +70,8 @@ class TestChannel(AioTestBase):
) )
with self.assertRaises(grpc.RpcError) as exception_context: with self.assertRaises(grpc.RpcError) as exception_context:
await hi(messages_pb2.SimpleRequest(), timeout=UNARY_CALL_WITH_SLEEP_VALUE / 2) await hi(messages_pb2.SimpleRequest(),
timeout=UNARY_CALL_WITH_SLEEP_VALUE / 2)
_, details = grpc.StatusCode.DEADLINE_EXCEEDED.value # pylint: disable=unused-variable _, details = grpc.StatusCode.DEADLINE_EXCEEDED.value # pylint: disable=unused-variable
self.assertEqual(grpc.StatusCode.DEADLINE_EXCEEDED, self.assertEqual(grpc.StatusCode.DEADLINE_EXCEEDED,
@ -89,7 +90,8 @@ class TestChannel(AioTestBase):
response_deserializer=messages_pb2.SimpleResponse.FromString, response_deserializer=messages_pb2.SimpleResponse.FromString,
) )
call = hi(messages_pb2.SimpleRequest(), timeout=UNARY_CALL_WITH_SLEEP_VALUE * 2) call = hi(messages_pb2.SimpleRequest(),
timeout=UNARY_CALL_WITH_SLEEP_VALUE * 2)
self.assertEqual(await call.code(), grpc.StatusCode.OK) self.assertEqual(await call.code(), grpc.StatusCode.OK)
async def test_unary_stream(self): async def test_unary_stream(self):

@ -22,7 +22,6 @@ from tests_aio.unit._test_server import start_test_server, UNARY_CALL_WITH_SLEEP
from tests_aio.unit._test_base import AioTestBase from tests_aio.unit._test_base import AioTestBase
from src.proto.grpc.testing import messages_pb2 from src.proto.grpc.testing import messages_pb2
_LOCAL_CANCEL_DETAILS_EXPECTATION = 'Locally cancelled by application!' _LOCAL_CANCEL_DETAILS_EXPECTATION = 'Locally cancelled by application!'
@ -234,8 +233,8 @@ class TestUnaryUnaryClientInterceptor(AioTestBase):
interceptor, interceptor_response = Interceptor(), ResponseInterceptor() interceptor, interceptor_response = Interceptor(), ResponseInterceptor()
async with aio.insecure_channel( async with aio.insecure_channel(
self._server_target, interceptors=[interceptor, self._server_target,
interceptor_response]) as channel: interceptors=[interceptor, interceptor_response]) as channel:
multicallable = channel.unary_unary( multicallable = channel.unary_unary(
'/grpc.testing.TestService/UnaryCall', '/grpc.testing.TestService/UnaryCall',
@ -277,7 +276,6 @@ class TestInterceptedUnaryUnaryCall(AioTestBase):
call = await continuation(client_call_details, request) call = await continuation(client_call_details, request)
return call return call
async with aio.insecure_channel(self._server_target, async with aio.insecure_channel(self._server_target,
interceptors=[Interceptor() interceptors=[Interceptor()
]) as channel: ]) as channel:
@ -307,7 +305,6 @@ class TestInterceptedUnaryUnaryCall(AioTestBase):
await call await call
return call return call
async with aio.insecure_channel(self._server_target, async with aio.insecure_channel(self._server_target,
interceptors=[Interceptor() interceptors=[Interceptor()
]) as channel: ]) as channel:
@ -336,7 +333,6 @@ class TestInterceptedUnaryUnaryCall(AioTestBase):
call = await continuation(client_call_details, request) call = await continuation(client_call_details, request)
return call return call
async with aio.insecure_channel(self._server_target, async with aio.insecure_channel(self._server_target,
interceptors=[Interceptor() interceptors=[Interceptor()
]) as channel: ]) as channel:
@ -346,7 +342,8 @@ class TestInterceptedUnaryUnaryCall(AioTestBase):
request_serializer=messages_pb2.SimpleRequest.SerializeToString, request_serializer=messages_pb2.SimpleRequest.SerializeToString,
response_deserializer=messages_pb2.SimpleResponse.FromString) response_deserializer=messages_pb2.SimpleResponse.FromString)
call = multicallable(messages_pb2.SimpleRequest(), timeout=UNARY_CALL_WITH_SLEEP_VALUE / 2) call = multicallable(messages_pb2.SimpleRequest(),
timeout=UNARY_CALL_WITH_SLEEP_VALUE / 2)
with self.assertRaises(aio.AioRpcError) as exception_context: with self.assertRaises(aio.AioRpcError) as exception_context:
await call await call
@ -369,7 +366,6 @@ class TestInterceptedUnaryUnaryCall(AioTestBase):
await call await call
return call return call
async with aio.insecure_channel(self._server_target, async with aio.insecure_channel(self._server_target,
interceptors=[Interceptor() interceptors=[Interceptor()
]) as channel: ]) as channel:
@ -379,7 +375,8 @@ class TestInterceptedUnaryUnaryCall(AioTestBase):
request_serializer=messages_pb2.SimpleRequest.SerializeToString, request_serializer=messages_pb2.SimpleRequest.SerializeToString,
response_deserializer=messages_pb2.SimpleResponse.FromString) response_deserializer=messages_pb2.SimpleResponse.FromString)
call = multicallable(messages_pb2.SimpleRequest(), timeout=UNARY_CALL_WITH_SLEEP_VALUE / 2) call = multicallable(messages_pb2.SimpleRequest(),
timeout=UNARY_CALL_WITH_SLEEP_VALUE / 2)
with self.assertRaises(aio.AioRpcError) as exception_context: with self.assertRaises(aio.AioRpcError) as exception_context:
await call await call
@ -406,7 +403,6 @@ class TestInterceptedUnaryUnaryCall(AioTestBase):
# This line should never be reached # This line should never be reached
raise Exception() raise Exception()
async with aio.insecure_channel(self._server_target, async with aio.insecure_channel(self._server_target,
interceptors=[Interceptor() interceptors=[Interceptor()
]) as channel: ]) as channel:
@ -450,7 +446,6 @@ class TestInterceptedUnaryUnaryCall(AioTestBase):
# This line should never be reached # This line should never be reached
raise Exception() raise Exception()
async with aio.insecure_channel(self._server_target, async with aio.insecure_channel(self._server_target,
interceptors=[Interceptor() interceptors=[Interceptor()
]) as channel: ]) as channel:
@ -489,7 +484,6 @@ class TestInterceptedUnaryUnaryCall(AioTestBase):
await call await call
return call return call
async with aio.insecure_channel(self._server_target, async with aio.insecure_channel(self._server_target,
interceptors=[Interceptor() interceptors=[Interceptor()
]) as channel: ]) as channel:
@ -521,7 +515,6 @@ class TestInterceptedUnaryUnaryCall(AioTestBase):
call.cancel() call.cancel()
return call return call
async with aio.insecure_channel(self._server_target, async with aio.insecure_channel(self._server_target,
interceptors=[Interceptor() interceptors=[Interceptor()
]) as channel: ]) as channel:

Loading…
Cancel
Save