mirror of https://github.com/python/cpython
without handler. (backport from rev. 56293)
This commit is contained in:
parent
ad4b263ba7
commit
40df67f704
|
@ -381,6 +381,12 @@ class MockPasswordManager:
|
||||||
|
|
||||||
class OpenerDirectorTests(unittest.TestCase):
|
class OpenerDirectorTests(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_add_non_handler(self):
|
||||||
|
class NonHandler(object):
|
||||||
|
pass
|
||||||
|
self.assertRaises(TypeError,
|
||||||
|
OpenerDirector().add_handler, NonHandler())
|
||||||
|
|
||||||
def test_badly_named_methods(self):
|
def test_badly_named_methods(self):
|
||||||
# test work-around for three methods that accidentally follow the
|
# test work-around for three methods that accidentally follow the
|
||||||
# naming conventions for handler methods
|
# naming conventions for handler methods
|
||||||
|
|
|
@ -298,6 +298,10 @@ class OpenerDirector:
|
||||||
self.process_request = {}
|
self.process_request = {}
|
||||||
|
|
||||||
def add_handler(self, handler):
|
def add_handler(self, handler):
|
||||||
|
if not hasattr(handler, "add_parent"):
|
||||||
|
raise TypeError("expected BaseHandler instance, got %r" %
|
||||||
|
type(handler))
|
||||||
|
|
||||||
added = False
|
added = False
|
||||||
for meth in dir(handler):
|
for meth in dir(handler):
|
||||||
if meth in ["redirect_request", "do_open", "proxy_open"]:
|
if meth in ["redirect_request", "do_open", "proxy_open"]:
|
||||||
|
|
Loading…
Reference in New Issue