MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_errors

Method test_errors

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

Source from the content-addressed store, hash-verified

1184 self.assertEqual(newreq.selector, '')
1185
1186 def test_errors(self):
1187 h = urllib.request.HTTPErrorProcessor()
1188 o = h.parent = MockOpener()
1189
1190 url = "http://example.com/"
1191 req = Request(url)
1192 # all 2xx are passed through
1193 r = MockResponse(200, "OK", {}, "", url)
1194 newr = h.http_response(req, r)
1195 self.assertIs(r, newr)
1196 self.assertNotHasAttr(o, "proto") # o.error not called
1197 r = MockResponse(202, "Accepted", {}, "", url)
1198 newr = h.http_response(req, r)
1199 self.assertIs(r, newr)
1200 self.assertNotHasAttr(o, "proto") # o.error not called
1201 r = MockResponse(206, "Partial content", {}, "", url)
1202 newr = h.http_response(req, r)
1203 self.assertIs(r, newr)
1204 self.assertNotHasAttr(o, "proto") # o.error not called
1205 # anything else calls o.error (and MockOpener returns None, here)
1206 r = MockResponse(502, "Bad gateway", {}, "", url)
1207 self.assertIsNone(h.http_response(req, r))
1208 self.assertEqual(o.proto, "http") # o.error called
1209 self.assertEqual(o.args, (req, r, 502, "Bad gateway", {}))
1210
1211 def test_cookies(self):
1212 cj = MockCookieJar()

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected