MCPcopy
hub / github.com/tornadoweb/tornado / connect_to_server

Method connect_to_server

tornado/test/iostream_test.py:1107–1133  ·  view source on GitHub ↗
(self, server_cls)

Source from the content-addressed store, hash-verified

1105class WaitForHandshakeTest(AsyncTestCase):
1106 @gen.coroutine
1107 def connect_to_server(self, server_cls):
1108 server = client = None
1109 try:
1110 sock, port = bind_unused_port()
1111 server = server_cls(ssl_options=_server_ssl_options())
1112 server.add_socket(sock)
1113
1114 ssl_ctx = ssl.create_default_context(ssl.Purpose.SERVER_AUTH)
1115 ssl_ctx.check_hostname = False
1116 ssl_ctx.verify_mode = ssl.CERT_NONE
1117 # These tests fail with ConnectionAbortedErrors with TLS
1118 # 1.3 on windows python 3.7.4 (which includes an upgrade
1119 # to openssl 1.1.c. Other platforms might be affected with
1120 # newer openssl too). Disable it until we figure out
1121 # what's up.
1122 # Update 2021-12-28: Still happening with Python 3.10 on
1123 # Windows. OP_NO_TLSv1_3 now raises a DeprecationWarning.
1124 with ignore_deprecation():
1125 ssl_ctx.options |= getattr(ssl, "OP_NO_TLSv1_3", 0)
1126 client = SSLIOStream(socket.socket(), ssl_options=ssl_ctx)
1127 yield client.connect(("127.0.0.1", port))
1128 self.assertIsNotNone(client.socket.cipher())
1129 finally:
1130 if server is not None:
1131 server.stop()
1132 if client is not None:
1133 client.close()
1134
1135 @gen_test
1136 def test_wait_for_handshake_future(self):

Calls 8

connectMethod · 0.95
bind_unused_portFunction · 0.90
ignore_deprecationFunction · 0.90
SSLIOStreamClass · 0.90
_server_ssl_optionsFunction · 0.85
add_socketMethod · 0.80
stopMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected