Namespaces | Functions | Variables
tests.unit.framework.common Namespace Reference

Namespaces

 test_constants
 
 test_control
 
 test_coverage
 

Functions

def bound_socket (bind_address='localhost', port=0, listen=True, sock_options=_DEFAULT_SOCK_OPTIONS)
 
def get_socket (bind_address='localhost', port=0, listen=True, sock_options=_DEFAULT_SOCK_OPTIONS)
 

Variables

tuple _DEFAULT_SOCK_OPTIONS
 
tuple _UNRECOVERABLE_ERRNOS = (errno.EADDRINUSE, errno.ENOSR)
 

Function Documentation

◆ bound_socket()

def tests.unit.framework.common.bound_socket (   bind_address = 'localhost',
  port = 0,
  listen = True,
  sock_options = _DEFAULT_SOCK_OPTIONS 
)
Opens a socket bound to an arbitrary port.

Useful for reserving a port for a system-under-test.

Args:
  bind_address: The host to which to bind.
  port: The port to which to bind.
  listen: A boolean value indicating whether or not to listen on the socket.
  sock_options: A sequence of socket options to apply to the socket.

Yields:
  A tuple containing:
    - the address to which the socket is bound
    - the port to which the socket is bound

Definition at line 76 of file src/python/grpcio_tests/tests/unit/framework/common/__init__.py.

◆ get_socket()

def tests.unit.framework.common.get_socket (   bind_address = 'localhost',
  port = 0,
  listen = True,
  sock_options = _DEFAULT_SOCK_OPTIONS 
)
Opens a socket.

Useful for reserving a port for a system-under-test.

Args:
  bind_address: The host to which to bind.
  port: The port to which to bind.
  listen: A boolean value indicating whether or not to listen on the socket.
  sock_options: A sequence of socket options to apply to the socket.

Returns:
  A tuple containing:
    - the address to which the socket is bound
    - the port to which the socket is bound
    - the socket object itself

Definition at line 26 of file src/python/grpcio_tests/tests/unit/framework/common/__init__.py.

Variable Documentation

◆ _DEFAULT_SOCK_OPTIONS

tuple tests.unit.framework.common._DEFAULT_SOCK_OPTIONS
private
Initial value:
1 = 'nt' else (
2  socket.SO_REUSEADDR,)

Definition at line 20 of file src/python/grpcio_tests/tests/unit/framework/common/__init__.py.

◆ _UNRECOVERABLE_ERRNOS

tuple tests.unit.framework.common._UNRECOVERABLE_ERRNOS = (errno.EADDRINUSE, errno.ENOSR)
private


grpc
Author(s):
autogenerated on Fri May 16 2025 03:03:53