def test_io_create_socket(self): connection = FakeConnection() io = IO(connection.parameters) addresses = io._get_socket_addresses() sock_address_tuple = addresses[0] sock = io._create_socket(socket_family=sock_address_tuple[0]) if hasattr(socket, 'socket'): self.assertIsInstance(sock, socket.socket) elif hasattr(socket, '_socketobject'): self.assertIsInstance(sock, socket._socketobject)
def test_io_create_ssl_socket(self): connection = FakeConnection() connection.parameters['ssl'] = True io = IO(connection.parameters) self.assertTrue(io.use_ssl) addresses = io._get_socket_addresses() sock_address_tuple = addresses[0] sock = io._create_socket(socket_family=sock_address_tuple[0]) if hasattr(socket, 'socket'): self.assertIsInstance(sock, socket.socket) if hasattr(ssl, 'SSLSocket'): self.assertIsInstance(sock, ssl.SSLSocket)
def test_io_create_ssl_socket(self): connection = FakeConnection() connection.parameters['ssl'] = True io = IO(connection.parameters) self.assertTrue(io.use_ssl) addresses = io._get_socket_addresses() sock_address_tuple = addresses[0] sock = io._create_socket(socket_family=sock_address_tuple[0]) if hasattr(socket, 'socket'): self.assertIsInstance(sock, socket.socket) if hasattr(ssl, 'SSLSocket'): self.assertIsInstance(sock, ssl.SSLSocket) self.assertTrue(connection.parameters['ssl_options']['ssl_version'])