diff --git a/src/python/grpcio_tests/tests/unit/_metadata_flags_test.py b/src/python/grpcio_tests/tests/unit/_metadata_flags_test.py index 59fb83708ce..c2d2aa7c2e3 100644 --- a/src/python/grpcio_tests/tests/unit/_metadata_flags_test.py +++ b/src/python/grpcio_tests/tests/unit/_metadata_flags_test.py @@ -229,7 +229,8 @@ class MetadataFlagsTest(unittest.TestCase): # Start the server after the connections are waiting wg.wait() server = test_common.test_server() - server.add_generic_rpc_handlers((_GenericHandler(weakref.proxy(self)),)) + server.add_generic_rpc_handlers((_GenericHandler( + weakref.proxy(self)),)) server.add_insecure_port(addr) server.start() diff --git a/src/python/grpcio_tests/tests/unit/framework/common/__init__.py b/src/python/grpcio_tests/tests/unit/framework/common/__init__.py index 70a66a7a864..79b6a603344 100644 --- a/src/python/grpcio_tests/tests/unit/framework/common/__init__.py +++ b/src/python/grpcio_tests/tests/unit/framework/common/__init__.py @@ -16,7 +16,9 @@ import contextlib import socket -def get_socket(bind_address='localhost', listen=True, sock_options=(socket.SO_REUSEPORT,)): +def get_socket(bind_address='localhost', + listen=True, + sock_options=(socket.SO_REUSEPORT,)): """Opens a socket bound to an arbitrary port. Useful for reserving a port for a system-under-test. @@ -44,11 +46,14 @@ def get_socket(bind_address='localhost', listen=True, sock_options=(socket.SO_RE return bind_address, sock.getsockname()[1], sock except socket.error: continue - raise RuntimeError("Failed to find to {} with sock_options {}".format(bind_address, sock_options)) + raise RuntimeError("Failed to bind to {} with sock_options {}".format( + bind_address, sock_options)) @contextlib.contextmanager -def bound_socket(bind_address='localhost', listen=True, sock_options=(socket.SO_REUSEPORT,)): +def bound_socket(bind_address='localhost', + listen=True, + sock_options=(socket.SO_REUSEPORT,)): """Opens a socket bound to an arbitrary port. Useful for reserving a port for a system-under-test. @@ -63,7 +68,8 @@ def bound_socket(bind_address='localhost', listen=True, sock_options=(socket.SO_ - the address to which the socket is bound - the port to which the socket is bound """ - host, port, sock = get_socket(bind_address=bind_address, listen=listen, sock_options=sock_options) + host, port, sock = get_socket( + bind_address=bind_address, listen=listen, sock_options=sock_options) try: yield host, port finally: diff --git a/src/python/grpcio_tests/tests_aio/unit/test_base.py b/src/python/grpcio_tests/tests_aio/unit/test_base.py index 22c79e0f825..a0078cd7d5c 100644 --- a/src/python/grpcio_tests/tests_aio/unit/test_base.py +++ b/src/python/grpcio_tests/tests_aio/unit/test_base.py @@ -24,6 +24,7 @@ from grpc.experimental import aio from tests_aio.unit import sync_server from tests.unit.framework.common import get_socket + def _get_free_loopback_tcp_port(): host, port, sock = get_socket(listen=False) return sock, "{}:{}".format(host, port)