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

Method setUp

tornado/test/iostream_test.py:1190–1214  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1188 # removed a manual hostname check that was needed only for very old
1189 # versions of python.
1190 def setUp(self):
1191 super().setUp()
1192 self.listener, self.port = bind_unused_port()
1193
1194 def accept_callback(connection, address):
1195 ssl_ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
1196 ssl_ctx.load_cert_chain(
1197 os.path.join(os.path.dirname(__file__), "test.crt"),
1198 os.path.join(os.path.dirname(__file__), "test.key"),
1199 )
1200 connection = ssl_ctx.wrap_socket(
1201 connection,
1202 server_side=True,
1203 do_handshake_on_connect=False,
1204 )
1205 SSLIOStream(connection)
1206
1207 netutil.add_accept_handler(self.listener, accept_callback)
1208
1209 # Our self-signed cert is its own CA. We have to pass the CA check before
1210 # the hostname check will be performed.
1211 self.client_ssl_ctx = ssl.create_default_context(ssl.Purpose.SERVER_AUTH)
1212 self.client_ssl_ctx.load_verify_locations(
1213 os.path.join(os.path.dirname(__file__), "test.crt")
1214 )
1215
1216 def tearDown(self):
1217 self.io_loop.remove_handler(self.listener.fileno())

Callers

nothing calls this directly

Calls 3

bind_unused_portFunction · 0.90
joinMethod · 0.80
setUpMethod · 0.45

Tested by

no test coverage detected