mirror of
https://github.com/python/cpython.git
synced 2025-08-28 20:56:54 +00:00
Followup to r83869 and issue #8524: rename socket.forget() to socket.detach()
and make it return the file descriptor.
This commit is contained in:
parent
30e86a4767
commit
6e451df800
6 changed files with 29 additions and 24 deletions
|
@ -655,17 +655,21 @@ class BasicTCPTest(SocketConnectedTest):
|
|||
self.serv_conn.send(MSG)
|
||||
self.serv_conn.shutdown(2)
|
||||
|
||||
def testForget(self):
|
||||
# Testing forget()
|
||||
f = self.cli_conn.fileno()
|
||||
self.cli_conn.forget()
|
||||
def testDetach(self):
|
||||
# Testing detach()
|
||||
fileno = self.cli_conn.fileno()
|
||||
f = self.cli_conn.detach()
|
||||
self.assertEqual(f, fileno)
|
||||
# cli_conn cannot be used anymore...
|
||||
self.assertRaises(socket.error, self.cli_conn.recv, 1024)
|
||||
self.cli_conn.close()
|
||||
# ...but we can create another socket using the (still open)
|
||||
# file descriptor
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, fileno=f)
|
||||
msg = sock.recv(1024)
|
||||
self.assertEqual(msg, MSG)
|
||||
|
||||
def _testForget(self):
|
||||
def _testDetach(self):
|
||||
self.serv_conn.send(MSG)
|
||||
|
||||
@unittest.skipUnless(thread, 'Threading required for this test.')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue