diff options
author | Benjamin Peterson <benjamin@python.org> | 2009-03-02 22:50:25 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2009-03-02 22:50:25 (GMT) |
commit | 6accb988a1822dc2927346ae4819aff8cc876b98 (patch) | |
tree | 42eaf66c7e2c74ae8dead53d95dcd812df7e318a /Lib/test/test_httplib.py | |
parent | a4f52b12d6e401f14f3c8e9e2d533eb448388bcc (diff) | |
download | cpython-6accb988a1822dc2927346ae4819aff8cc876b98.zip cpython-6accb988a1822dc2927346ae4819aff8cc876b98.tar.gz cpython-6accb988a1822dc2927346ae4819aff8cc876b98.tar.bz2 |
Merged revisions 70107 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r70107 | benjamin.peterson | 2009-03-02 16:41:42 -0600 (Mon, 02 Mar 2009) | 1 line
give httplib.IncompleteRead a more sane repr #4308
........
Diffstat (limited to 'Lib/test/test_httplib.py')
-rw-r--r-- | Lib/test/test_httplib.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py index 099f803..a433474 100644 --- a/Lib/test/test_httplib.py +++ b/Lib/test/test_httplib.py @@ -181,6 +181,8 @@ class BasicTest(TestCase): resp.read() except httplib.IncompleteRead as i: self.assertEquals(i.partial, b'hello world') + self.assertEqual(repr(i),'IncompleteRead(11 bytes read)') + self.assertEqual(str(i),'IncompleteRead(11 bytes read)') else: self.fail('IncompleteRead expected') finally: @@ -194,6 +196,23 @@ class BasicTest(TestCase): self.assertEquals(resp.read(), b'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, b'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): |