(self)
| 801 | self.assertTrue(resp.closed) |
| 802 | |
| 803 | def test_partial_readintos(self): |
| 804 | # if we have Content-Length, HTTPResponse knows when to close itself, |
| 805 | # the same behaviour as when we read the whole thing with read() |
| 806 | body = "HTTP/1.1 200 Ok\r\nContent-Length: 4\r\n\r\nText" |
| 807 | sock = FakeSocket(body) |
| 808 | resp = client.HTTPResponse(sock) |
| 809 | resp.begin() |
| 810 | b = bytearray(2) |
| 811 | n = resp.readinto(b) |
| 812 | self.assertEqual(n, 2) |
| 813 | self.assertEqual(bytes(b), b'Te') |
| 814 | self.assertFalse(resp.isclosed()) |
| 815 | n = resp.readinto(b) |
| 816 | self.assertEqual(n, 2) |
| 817 | self.assertEqual(bytes(b), b'xt') |
| 818 | self.assertTrue(resp.isclosed()) |
| 819 | self.assertFalse(resp.closed) |
| 820 | resp.close() |
| 821 | self.assertTrue(resp.closed) |
| 822 | |
| 823 | def test_partial_reads_past_end(self): |
| 824 | # if we have Content-Length, clip reads to the end |
nothing calls this directly
no test coverage detected