Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(56498)

Unified Diff: Lib/test/test_httplib.py

Issue 16723: io.TextIOWrapper on urllib.request.urlopen terminates prematurely
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/http/client.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/test/test_httplib.py Sat Jan 26 19:00:20 2013 +0100
+++ b/Lib/test/test_httplib.py Sat Jan 26 22:05:22 2013 +0200
@@ -166,6 +166,9 @@
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)
@@ -187,6 +190,9 @@
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_readintos(self):
# if we have a length, the system knows when to close itself
@@ -204,6 +210,9 @@
self.assertEqual(n, 2)
self.assertEqual(bytes(b), 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
@@ -217,6 +226,9 @@
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_readintos_no_content_length(self):
# when no length is present, the socket should be gracefully closed when
@@ -236,6 +248,9 @@
n = resp.readinto(b)
self.assertEqual(n, 0)
self.assertTrue(resp.isclosed())
+ self.assertFalse(resp.closed)
+ resp.close()
+ self.assertTrue(resp.closed)
def test_host_port(self):
# Check invalid host_port
@@ -463,6 +478,9 @@
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_readinto_chunked_head(self):
chunked_start = (
@@ -483,6 +501,9 @@
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(
@@ -559,6 +580,9 @@
resp.begin()
self.assertEqual(resp.read(), b'')
self.assertTrue(resp.isclosed())
+ self.assertFalse(resp.closed)
+ resp.close()
+ self.assertTrue(resp.closed)
def test_delayed_ack_opt(self):
# Test that Nagle/delayed_ack optimistaion works correctly.
« no previous file with comments | « Lib/http/client.py ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+