MCPcopy Index your code
hub / github.com/RustPython/RustPython / testDetach

Method testDetach

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

Source from the content-addressed store, hash-verified

3073 self.serv_conn.shutdown(2)
3074
3075 def testDetach(self):
3076 # Testing detach()
3077 fileno = self.cli_conn.fileno()
3078 f = self.cli_conn.detach()
3079 self.assertEqual(f, fileno)
3080 # cli_conn cannot be used anymore...
3081 self.assertTrue(self.cli_conn._closed)
3082 self.assertRaises(OSError, self.cli_conn.recv, 1024)
3083 self.cli_conn.close()
3084 # ...but we can create another socket using the (still open)
3085 # file descriptor
3086 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, fileno=f)
3087 self.addCleanup(sock.close)
3088 msg = sock.recv(1024)
3089 self.assertEqual(msg, MSG)
3090
3091 def _testDetach(self):
3092 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