mirror of
https://github.com/python/cpython.git
synced 2025-08-02 08:02:56 +00:00
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.
This commit is contained in:
parent
9f87128d8b
commit
9fab9f103f
2 changed files with 14 additions and 4 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue