summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_socket.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-08-08 23:24:50 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-08-08 23:24:50 (GMT)
commite43f9d0ed69addbc34bac4af1b3ad7f1bdd3b149 (patch)
treee15aa8c051472ddb7ec9a684d9a4e546ee3e14ca /Lib/test/test_socket.py
parentba8a98600eddc5e2a87a9148e634ada1a1056495 (diff)
downloadcpython-e43f9d0ed69addbc34bac4af1b3ad7f1bdd3b149.zip
cpython-e43f9d0ed69addbc34bac4af1b3ad7f1bdd3b149.tar.gz
cpython-e43f9d0ed69addbc34bac4af1b3ad7f1bdd3b149.tar.bz2
Issue #8524: Add a forget() method to socket objects, so as to put the
socket into the closed state without closing the underlying file descriptor.
Diffstat (limited to 'Lib/test/test_socket.py')
-rw-r--r--Lib/test/test_socket.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index 25025dd..ae34c11 100644
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -655,6 +655,19 @@ 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()
+ self.assertRaises(socket.error, self.cli_conn.recv, 1024)
+ self.cli_conn.close()
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, fileno=f)
+ msg = sock.recv(1024)
+ self.assertEqual(msg, MSG)
+
+ def _testForget(self):
+ self.serv_conn.send(MSG)
+
@unittest.skipUnless(thread, 'Threading required for this test.')
class BasicUDPTest(ThreadedUDPSocketTest):