MCPcopy Index your code
hub / github.com/python/cpython / test_errors

Method test_errors

Lib/test/test_urllib2.py:1203–1226  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1201 self.assertEqual(newreq.selector, '')
1202
1203 def test_errors(self):
1204 h = urllib.request.HTTPErrorProcessor()
1205 o = h.parent = MockOpener()
1206
1207 url = "http://example.com/"
1208 req = Request(url)
1209 # all 2xx are passed through
1210 r = MockResponse(200, "OK", {}, "", url)
1211 newr = h.http_response(req, r)
1212 self.assertIs(r, newr)
1213 self.assertNotHasAttr(o, "proto") # o.error not called
1214 r = MockResponse(202, "Accepted", {}, "", url)
1215 newr = h.http_response(req, r)
1216 self.assertIs(r, newr)
1217 self.assertNotHasAttr(o, "proto") # o.error not called
1218 r = MockResponse(206, "Partial content", {}, "", url)
1219 newr = h.http_response(req, r)
1220 self.assertIs(r, newr)
1221 self.assertNotHasAttr(o, "proto") # o.error not called
1222 # anything else calls o.error (and MockOpener returns None, here)
1223 r = MockResponse(502, "Bad gateway", {}, "", url)
1224 self.assertIsNone(h.http_response(req, r))
1225 self.assertEqual(o.proto, "http") # o.error called
1226 self.assertEqual(o.args, (req, r, 502, "Bad gateway", {}))
1227
1228 def test_cookies(self):
1229 cj = MockCookieJar()

Callers

nothing calls this directly

Calls 8

http_responseMethod · 0.95
RequestClass · 0.90
MockOpenerClass · 0.85
MockResponseClass · 0.85
assertNotHasAttrMethod · 0.80
assertIsNoneMethod · 0.80
assertIsMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected