summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_urllib2.py
diff options
context:
space:
mode:
authorFacundo Batista <facundobatista@gmail.com>2007-04-23 17:08:31 (GMT)
committerFacundo Batista <facundobatista@gmail.com>2007-04-23 17:08:31 (GMT)
commit9fab9f103f21b42ffafc87ff5a4ce970735a7b17 (patch)
tree448fa248d3060f85a6cfc1f9a70eb7434c65d4ea /Lib/test/test_urllib2.py
parent9f87128d8b6282e3c1afd2cd08150e5f5de14290 (diff)
downloadcpython-9fab9f103f21b42ffafc87ff5a4ce970735a7b17.zip
cpython-9fab9f103f21b42ffafc87ff5a4ce970735a7b17.tar.gz
cpython-9fab9f103f21b42ffafc87ff5a4ce970735a7b17.tar.bz2
As specified in RFC 2616, 2xx code indicates that the client's
request was successfully received, understood, and accepted. Now in these cases no error is raised. Also fixed tests.
Diffstat (limited to 'Lib/test/test_urllib2.py')
-rw-r--r--Lib/test/test_urllib2.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py
index a23d61e..1a2986a 100644
--- a/Lib/test/test_urllib2.py
+++ b/Lib/test/test_urllib2.py
@@ -766,16 +766,24 @@ class HandlerTests(unittest.TestCase):
url = "http://example.com/"
req = Request(url)
- # 200 OK is passed through
+ # all 2xx are passed through
r = MockResponse(200, "OK", {}, "", url)
newr = h.http_response(req, r)
self.assert_(r is newr)
self.assert_(not hasattr(o, "proto")) # o.error not called
+ r = MockResponse(202, "Accepted", {}, "", url)
+ newr = h.http_response(req, r)
+ self.assert_(r is newr)
+ self.assert_(not hasattr(o, "proto")) # o.error not called
+ r = MockResponse(206, "Partial content", {}, "", url)
+ newr = h.http_response(req, r)
+ self.assert_(r is newr)
+ self.assert_(not hasattr(o, "proto")) # o.error not called
# anything else calls o.error (and MockOpener returns None, here)
- r = MockResponse(201, "Created", {}, "", url)
+ r = MockResponse(502, "Bad gateway", {}, "", url)
self.assert_(h.http_response(req, r) is None)
self.assertEqual(o.proto, "http") # o.error called
- self.assertEqual(o.args, (req, r, 201, "Created", {}))
+ self.assertEqual(o.args, (req, r, 502, "Bad gateway", {}))
def test_cookies(self):
cj = MockCookieJar()