File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -577,6 +577,23 @@ class NonHandler(object):
577577 self .assertRaises (TypeError ,
578578 OpenerDirector ().add_handler , NonHandler ())
579579
580+ def test_no_protocol_methods (self ):
581+ # test the case that methods starts with handler type without the protocol
582+ # like open*() or _open*().
583+ # These methods should be ignored
584+
585+ o = OpenerDirector ()
586+ meth_spec = [
587+ ["open" ],
588+ ["_open" ],
589+ ["error" ]
590+ ]
591+
592+ add_ordered_mock_handlers (o , meth_spec )
593+
594+ self .assertEqual (len (o .handle_open ), 0 )
595+ self .assertEqual (len (o .handle_error ), 0 )
596+
580597 def test_badly_named_methods (self ):
581598 # test work-around for three methods that accidentally follow the
582599 # naming conventions for handler methods
Original file line number Diff line number Diff line change @@ -415,6 +415,8 @@ def add_handler(self, handler):
415415 continue
416416
417417 i = meth .find ("_" )
418+ if i < 1 :
419+ continue
418420 protocol = meth [:i ]
419421 condition = meth [i + 1 :]
420422
You can’t perform that action at this time.
0 commit comments