summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_socket.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-09-14 15:28:10 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-09-14 15:28:10 (GMT)
commit1e7ee9dfa0cc5007da1cbc3331b799584af8b680 (patch)
tree2dc6743ca8f3def1ffbb1eafb5d488322adcd4e2 /Lib/test/test_socket.py
parente0add764688a3f3237749e0c2830b669d2c76ca0 (diff)
downloadcpython-1e7ee9dfa0cc5007da1cbc3331b799584af8b680.zip
cpython-1e7ee9dfa0cc5007da1cbc3331b799584af8b680.tar.gz
cpython-1e7ee9dfa0cc5007da1cbc3331b799584af8b680.tar.bz2
Issue #15842: the SocketIO.{readable,writable,seekable} methods now raise ValueError when the file-like object is closed.
Patch by Alessandro Moura.
Diffstat (limited to 'Lib/test/test_socket.py')
-rw-r--r--Lib/test/test_socket.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index cce0d1b..e2ed21d 100644
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -839,6 +839,17 @@ class GeneralModuleTests(unittest.TestCase):
fp.close()
self.assertEqual(repr(fp), "<_io.BufferedReader name=-1>")
+ def test_unusable_closed_socketio(self):
+ with socket.socket() as sock:
+ fp = sock.makefile("rb", buffering=0)
+ self.assertTrue(fp.readable())
+ self.assertFalse(fp.writable())
+ self.assertFalse(fp.seekable())
+ fp.close()
+ self.assertRaises(ValueError, fp.readable)
+ self.assertRaises(ValueError, fp.writable)
+ self.assertRaises(ValueError, fp.seekable)
+
def testListenBacklog0(self):
srv = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
srv.bind((HOST, 0))