@@ -1495,18 +1495,34 @@ def test_url_fragment(self):
14951495 req = Request (url )
14961496 self .assertEqual (req .get_full_url (), url )
14971497
1498- def test_HTTPError_interface ():
1499- """
1500- Issue 13211 reveals that HTTPError didn't implement the URLError
1501- interface even though HTTPError is a subclass of URLError.
1502-
1503- >>> msg = 'something bad happened'
1504- >>> url = code = hdrs = fp = None
1505- >>> err = urllib.error.HTTPError(url, code, msg, hdrs, fp)
1506- >>> assert hasattr(err, 'reason')
1507- >>> err.reason
1508- 'something bad happened'
1509- """
1498+ def test_HTTPError_interface (self ):
1499+ """
1500+ Issue 13211 reveals that HTTPError didn't implement the URLError
1501+ interface even though HTTPError is a subclass of URLError.
1502+
1503+ >>> msg = 'something bad happened'
1504+ >>> url = code = hdrs = fp = None
1505+ >>> err = urllib.error.HTTPError(url, code, msg, hdrs, fp)
1506+ >>> assert hasattr(err, 'reason')
1507+ >>> err.reason
1508+ 'something bad happened'
1509+ """
1510+
1511+ def test_HTTPError_interface_call (self ):
1512+ """
1513+ Issue 15701 - HTTPError interface has info method available from URLError
1514+ """
1515+ err = urllib .request .HTTPError (msg = "something bad happened" , url = None ,
1516+ code = None , hdrs = 'Content-Length:42' , fp = None )
1517+ self .assertTrue (hasattr (err , 'reason' ))
1518+ assert hasattr (err , 'reason' )
1519+ assert hasattr (err , 'info' )
1520+ assert callable (err .info )
1521+ try :
1522+ err .info ()
1523+ except AttributeError :
1524+ self .fail ('err.info call failed.' )
1525+ self .assertEqual (err .info (), "Content-Length:42" )
15101526
15111527def test_main (verbose = None ):
15121528 from test import test_urllib2
0 commit comments