mirror of
https://github.com/python/cpython.git
synced 2025-07-31 07:04:42 +00:00
give httplib.IncompleteRead a more sane repr #4308
This commit is contained in:
parent
ce45a967c2
commit
7d49bba969
4 changed files with 34 additions and 2 deletions
|
@ -185,6 +185,8 @@ class BasicTest(TestCase):
|
|||
resp.read()
|
||||
except httplib.IncompleteRead, i:
|
||||
self.assertEquals(i.partial, 'hello world')
|
||||
self.assertEqual(repr(i),'IncompleteRead(11 bytes read)')
|
||||
self.assertEqual(str(i),'IncompleteRead(11 bytes read)')
|
||||
else:
|
||||
self.fail('IncompleteRead expected')
|
||||
finally:
|
||||
|
@ -198,6 +200,23 @@ class BasicTest(TestCase):
|
|||
self.assertEquals(resp.read(), 'Hello\r\n')
|
||||
resp.close()
|
||||
|
||||
def test_incomplete_read(self):
|
||||
sock = FakeSocket('HTTP/1.1 200 OK\r\nContent-Length: 10\r\n\r\nHello\r\n')
|
||||
resp = httplib.HTTPResponse(sock, method="GET")
|
||||
resp.begin()
|
||||
try:
|
||||
resp.read()
|
||||
except httplib.IncompleteRead as i:
|
||||
self.assertEquals(i.partial, 'Hello\r\n')
|
||||
self.assertEqual(repr(i),
|
||||
"IncompleteRead(7 bytes read, 3 more expected)")
|
||||
self.assertEqual(str(i),
|
||||
"IncompleteRead(7 bytes read, 3 more expected)")
|
||||
else:
|
||||
self.fail('IncompleteRead expected')
|
||||
finally:
|
||||
resp.close()
|
||||
|
||||
|
||||
class OfflineTest(TestCase):
|
||||
def test_responses(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue