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

Method test_handler_order

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

Source from the content-addressed store, hash-verified

625 self.assertEqual(args, (req,))
626
627 def test_handler_order(self):
628 o = OpenerDirector()
629 handlers = []
630 for meths, handler_order in [([("http_open", "return self")], 500),
631 (["http_open"], 0)]:
632 class MockHandlerSubclass(MockHandler):
633 pass
634
635 h = MockHandlerSubclass(meths)
636 h.handler_order = handler_order
637 handlers.append(h)
638 o.add_handler(h)
639
640 o.open("http://example.com/")
641 # handlers called in reverse order, thanks to their sort order
642 self.assertEqual(o.calls[0][0], handlers[1])
643 self.assertEqual(o.calls[1][0], handlers[0])
644
645 def test_raise(self):
646 # raising URLError stops processing of request

Callers

nothing calls this directly

Calls 6

add_handlerMethod · 0.95
openMethod · 0.95
OpenerDirectorClass · 0.90
MockHandlerSubclassClass · 0.70
appendMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected