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

Method test_non_blocking_connect_ex

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

Source from the content-addressed store, hash-verified

2109 self.assertTrue(s.getpeercert())
2110
2111 def test_non_blocking_connect_ex(self):
2112 # Issue #11326: non-blocking connect_ex() should allow handshake
2113 # to proceed after the socket gets ready.
2114 s = test_wrap_socket(socket.socket(socket.AF_INET),
2115 cert_reqs=ssl.CERT_REQUIRED,
2116 ca_certs=SIGNING_CA,
2117 do_handshake_on_connect=False)
2118 self.addCleanup(s.close)
2119 s.setblocking(False)
2120 rc = s.connect_ex(self.server_addr)
2121 # EWOULDBLOCK under Windows, EINPROGRESS elsewhere
2122 self.assertIn(rc, (0, errno.EINPROGRESS, errno.EWOULDBLOCK))
2123 # Wait for connect to finish
2124 select.select([], [s], [], 5.0)
2125 # Non-blocking handshake
2126 while True:
2127 try:
2128 s.do_handshake()
2129 break
2130 except ssl.SSLWantReadError:
2131 select.select([s], [], [], 5.0)
2132 except ssl.SSLWantWriteError:
2133 select.select([], [s], [], 5.0)
2134 # SSL established
2135 self.assertTrue(s.getpeercert())
2136
2137 def test_connect_with_context(self):
2138 # Same as test_connect, but with a separately created context

Callers

nothing calls this directly

Calls 10

test_wrap_socketFunction · 0.85
socketMethod · 0.80
addCleanupMethod · 0.80
connect_exMethod · 0.80
assertInMethod · 0.80
assertTrueMethod · 0.80
setblockingMethod · 0.45
selectMethod · 0.45
do_handshakeMethod · 0.45
getpeercertMethod · 0.45

Tested by

no test coverage detected