diff options
author | Benjamin Peterson <benjamin@python.org> | 2009-03-02 22:41:42 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2009-03-02 22:41:42 (GMT) |
commit | 7d49bba969a6ca490ade6aa908e350d3c05f76f4 (patch) | |
tree | f3c3dbd9573fda44d86f40f9c1b9ff9fa7707529 /Lib/test | |
parent | ce45a967c2d82a6b3112c5621993f5fec1dd5ea1 (diff) | |
download | cpython-7d49bba969a6ca490ade6aa908e350d3c05f76f4.zip cpython-7d49bba969a6ca490ade6aa908e350d3c05f76f4.tar.gz cpython-7d49bba969a6ca490ade6aa908e350d3c05f76f4.tar.bz2 |
give httplib.IncompleteRead a more sane repr #4308
Diffstat (limited to 'Lib/test')
-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 c8c0648..54a2b0e 100644 --- a/Lib/test/test_httplib.py +++ b/Lib/test/test_httplib.py @@ -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): |