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

Method test_http_error

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

Source from the content-addressed store, hash-verified

656 self.assertEqual(o.calls, [(handlers[0], "http_open", (req,), {})])
657
658 def test_http_error(self):
659 # XXX http_error_default
660 # http errors are a special case
661 o = OpenerDirector()
662 meth_spec = [
663 [("http_open", "error 302")],
664 [("http_error_400", "raise"), "http_open"],
665 [("http_error_302", "return response"), "http_error_303",
666 "http_error"],
667 [("http_error_302")],
668 ]
669 handlers = add_ordered_mock_handlers(o, meth_spec)
670 req = Request("http://example.com/")
671 o.open(req)
672 assert len(o.calls) == 2
673 calls = [(handlers[0], "http_open", (req,)),
674 (handlers[2], "http_error_302",
675 (req, support.ALWAYS_EQ, 302, "", {}))]
676 for expected, got in zip(calls, o.calls):
677 handler, method_name, args = expected
678 self.assertEqual((handler, method_name), got[:2])
679 self.assertEqual(args, got[2])
680
681 def test_processors(self):
682 # *_request / *_response methods get called appropriately

Callers

nothing calls this directly

Calls 6

openMethod · 0.95
OpenerDirectorClass · 0.90
RequestClass · 0.90
lenFunction · 0.85
assertEqualMethod · 0.45

Tested by

no test coverage detected