summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_socket.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2011-02-25 23:14:08 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2011-02-25 23:14:08 (GMT)
commit5d5381ed002a03486b7364f9ae8b69fa2d2a1ede (patch)
treeba7cb90afdfceb2bfe0fa733710abcd5227baf36 /Lib/test/test_socket.py
parent7d9d34f18ab8a103e2ba7077293b49c861236547 (diff)
downloadcpython-5d5381ed002a03486b7364f9ae8b69fa2d2a1ede.zip
cpython-5d5381ed002a03486b7364f9ae8b69fa2d2a1ede.tar.gz
cpython-5d5381ed002a03486b7364f9ae8b69fa2d2a1ede.tar.bz2
Merged revisions 88622 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r88622 | antoine.pitrou | 2011-02-26 00:07:44 +0100 (sam., 26 févr. 2011) | 5 lines Issue #7322: Trying to read from a socket's file-like object after a timeout occurred now raises an error instead of silently losing data. Patch by Ross Lagerwall. ........
Diffstat (limited to 'Lib/test/test_socket.py')
-rw-r--r--Lib/test/test_socket.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index 23d22a8..9ba391e 100644
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -1109,6 +1109,23 @@ class FileObjectClassTestCase(SocketConnectedTest):
self.write_file = None
SocketConnectedTest.clientTearDown(self)
+ def testReadAfterTimeout(self):
+ # Issue #7322: A file object must disallow further reads
+ # after a timeout has occurred.
+ self.cli_conn.settimeout(1)
+ self.read_file.read(3)
+ # First read raises a timeout
+ self.assertRaises(socket.timeout, self.read_file.read, 1)
+ # Second read is disallowed
+ with self.assertRaises(IOError) as ctx:
+ self.read_file.read(1)
+ self.assertIn("cannot read from timed out object", str(ctx.exception))
+
+ def _testReadAfterTimeout(self):
+ self.write_file.write(self.write_msg[0:3])
+ self.write_file.flush()
+ self.serv_finished.wait()
+
def testSmallRead(self):
# Performing small file read test
first_seg = self.read_file.read(len(self.read_msg)-3)