(self)
| 847 | self.assertTrue(resp.closed) |
| 848 | |
| 849 | def test_partial_readintos(self): |
| 850 | # if we have Content-Length, HTTPResponse knows when to close itself, |
| 851 | # the same behaviour as when we read the whole thing with read() |
| 852 | body = "HTTP/1.1 200 Ok\r\nContent-Length: 4\r\n\r\nText" |
| 853 | sock = FakeSocket(body) |
| 854 | resp = client.HTTPResponse(sock) |
| 855 | resp.begin() |
| 856 | b = bytearray(2) |
| 857 | n = resp.readinto(b) |
| 858 | self.assertEqual(n, 2) |
| 859 | self.assertEqual(bytes(b), b'Te') |
| 860 | self.assertFalse(resp.isclosed()) |
| 861 | n = resp.readinto(b) |
| 862 | self.assertEqual(n, 2) |
| 863 | self.assertEqual(bytes(b), b'xt') |
| 864 | self.assertTrue(resp.isclosed()) |
| 865 | self.assertFalse(resp.closed) |
| 866 | resp.close() |
| 867 | self.assertTrue(resp.closed) |
| 868 | |
| 869 | def test_partial_reads_past_end(self): |
| 870 | # if we have Content-Length, clip reads to the end |
nothing calls this directly
no test coverage detected