diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-02-06 08:31:57 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-02-06 08:31:57 (GMT) |
commit | b5b9c8cd402b8ab8d6cb00f157ac855b37a1e5c6 (patch) | |
tree | c7aa684b08583ff7093928d4a2a6b641013c5c64 /Lib/test/test_httplib.py | |
parent | f581b372003de0ae604c14a1f1dc2e8c36ea277b (diff) | |
download | cpython-b5b9c8cd402b8ab8d6cb00f157ac855b37a1e5c6.zip cpython-b5b9c8cd402b8ab8d6cb00f157ac855b37a1e5c6.tar.gz cpython-b5b9c8cd402b8ab8d6cb00f157ac855b37a1e5c6.tar.bz2 |
Issue #16723: httplib.HTTPResponse no longer marked closed when the connection
is automatically closed.
Diffstat (limited to 'Lib/test/test_httplib.py')
-rw-r--r-- | Lib/test/test_httplib.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py index 5df4b51..420302c 100644 --- a/Lib/test/test_httplib.py +++ b/Lib/test/test_httplib.py @@ -164,6 +164,9 @@ class BasicTest(TestCase): resp.begin() self.assertEqual(resp.read(), b"Text") self.assertTrue(resp.isclosed()) + self.assertFalse(resp.closed) + resp.close() + self.assertTrue(resp.closed) body = "HTTP/1.1 400.100 Not Ok\r\n\r\nText" sock = FakeSocket(body) @@ -185,6 +188,9 @@ class BasicTest(TestCase): self.assertFalse(resp.isclosed()) self.assertEqual(resp.read(2), b'xt') self.assertTrue(resp.isclosed()) + self.assertFalse(resp.closed) + resp.close() + self.assertTrue(resp.closed) def test_partial_reads_no_content_length(self): # when no length is present, the socket should be gracefully closed when @@ -198,6 +204,9 @@ class BasicTest(TestCase): self.assertEqual(resp.read(2), b'xt') self.assertEqual(resp.read(1), b'') self.assertTrue(resp.isclosed()) + self.assertFalse(resp.closed) + resp.close() + self.assertTrue(resp.closed) def test_partial_reads_incomplete_body(self): # if the server shuts down the connection before the whole @@ -211,6 +220,9 @@ class BasicTest(TestCase): self.assertEqual(resp.read(2), b'xt') self.assertEqual(resp.read(1), b'') self.assertTrue(resp.isclosed()) + self.assertFalse(resp.closed) + resp.close() + self.assertTrue(resp.closed) def test_host_port(self): # Check invalid host_port @@ -355,6 +367,9 @@ class BasicTest(TestCase): self.assertEqual(resp.status, 200) self.assertEqual(resp.reason, 'OK') self.assertTrue(resp.isclosed()) + self.assertFalse(resp.closed) + resp.close() + self.assertTrue(resp.closed) def test_negative_content_length(self): sock = FakeSocket( @@ -430,6 +445,9 @@ class BasicTest(TestCase): resp.begin() self.assertEqual(resp.read(), b'') self.assertTrue(resp.isclosed()) + self.assertFalse(resp.closed) + resp.close() + self.assertTrue(resp.closed) class OfflineTest(TestCase): def test_responses(self): |