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

Method testDetach

Lib/test/test_socket.py:3178–3192  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3176 self.serv_conn.shutdown(2)
3177
3178 def testDetach(self):
3179 # Testing detach()
3180 fileno = self.cli_conn.fileno()
3181 f = self.cli_conn.detach()
3182 self.assertEqual(f, fileno)
3183 # cli_conn cannot be used anymore...
3184 self.assertTrue(self.cli_conn._closed)
3185 self.assertRaises(OSError, self.cli_conn.recv, 1024)
3186 self.cli_conn.close()
3187 # ...but we can create another socket using the (still open)
3188 # file descriptor
3189 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, fileno=f)
3190 self.addCleanup(sock.close)
3191 msg = sock.recv(1024)
3192 self.assertEqual(msg, MSG)
3193
3194 def _testDetach(self):
3195 self.serv_conn.send(MSG)

Callers

nothing calls this directly

Calls 9

assertTrueMethod · 0.80
socketMethod · 0.80
addCleanupMethod · 0.80
filenoMethod · 0.45
detachMethod · 0.45
assertEqualMethod · 0.45
assertRaisesMethod · 0.45
closeMethod · 0.45
recvMethod · 0.45

Tested by

no test coverage detected