(self)
| 595 | self.assertEqual(len(o.handle_error), 0) |
| 596 | |
| 597 | def test_badly_named_methods(self): |
| 598 | # test work-around for three methods that accidentally follow the |
| 599 | # naming conventions for handler methods |
| 600 | # (*_open() / *_request() / *_response()) |
| 601 | |
| 602 | # These used to call the accidentally-named methods, causing a |
| 603 | # TypeError in real code; here, returning self from these mock |
| 604 | # methods would either cause no exception, or AttributeError. |
| 605 | |
| 606 | from urllib.error import URLError |
| 607 | |
| 608 | o = OpenerDirector() |
| 609 | meth_spec = [ |
| 610 | [("do_open", "return self"), ("proxy_open", "return self")], |
| 611 | [("redirect_request", "return self")], |
| 612 | ] |
| 613 | add_ordered_mock_handlers(o, meth_spec) |
| 614 | o.add_handler(urllib.request.UnknownHandler()) |
| 615 | for scheme in "do", "proxy", "redirect": |
| 616 | self.assertRaises(URLError, o.open, scheme+"://example.com/") |
| 617 | |
| 618 | def test_handled(self): |
| 619 | # handler returning non-None means no more handlers will be called |
nothing calls this directly
no test coverage detected