mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
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. ........
This commit is contained in:
parent
7d9d34f18a
commit
5d5381ed00
3 changed files with 26 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue