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

Method test_handler_order

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

Source from the content-addressed store, hash-verified

642 self.assertEqual(args, (req,))
643
644 def test_handler_order(self):
645 o = OpenerDirector()
646 handlers = []
647 for meths, handler_order in [([("http_open", "return self")], 500),
648 (["http_open"], 0)]:
649 class MockHandlerSubclass(MockHandler):
650 pass
651
652 h = MockHandlerSubclass(meths)
653 h.handler_order = handler_order
654 handlers.append(h)
655 o.add_handler(h)
656
657 o.open("http://example.com/")
658 # handlers called in reverse order, thanks to their sort order
659 self.assertEqual(o.calls[0][0], handlers[1])
660 self.assertEqual(o.calls[1][0], handlers[0])
661
662 def test_raise(self):
663 # 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