MCPcopy Index your code
hub / github.com/python/cpython / test_context_setget

Method test_context_setget

Lib/test/test_ssl.py:2324–2337  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2322 self.assertEqual(len(ctx.get_ca_certs()), 1)
2323
2324 def test_context_setget(self):
2325 # Check that the context of a connected socket can be replaced.
2326 ctx1 = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
2327 ctx1.load_verify_locations(capath=CAPATH)
2328 ctx2 = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
2329 ctx2.load_verify_locations(capath=CAPATH)
2330 s = socket.socket(socket.AF_INET)
2331 with ctx1.wrap_socket(s, server_hostname='localhost') as ss:
2332 ss.connect(self.server_addr)
2333 self.assertIs(ss.context, ctx1)
2334 self.assertIs(ss._sslobj.context, ctx1)
2335 ss.context = ctx2
2336 self.assertIs(ss.context, ctx2)
2337 self.assertIs(ss._sslobj.context, ctx2)
2338
2339 def ssl_io_loop(self, sock, incoming, outgoing, func, *args, **kwargs):
2340 # A simple IO loop. Call func(*args) depending on the error we get

Callers

nothing calls this directly

Calls 4

wrap_socketMethod · 0.95
socketMethod · 0.80
connectMethod · 0.45
assertIsMethod · 0.45

Tested by

no test coverage detected