Skip to content

Commit 2a4d245

Browse files
committed
#17471 - Increasing the urllib.error test coverage. Bringing it to 100%. Based on patch contributed by Daniel Wozniak
1 parent ece1222 commit 2a4d245

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Lib/test/test_urllib2.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1446,10 +1446,18 @@ def test_HTTPError_interface(self):
14461446
Issue 13211 reveals that HTTPError didn't implement the URLError
14471447
interface even though HTTPError is a subclass of URLError.
14481448
1449-
>>> err = urllib.error.HTTPError(msg='something bad happened', url=None, code=None, hdrs=None, fp=None)
1449+
>>> msg = 'something bad happened'
1450+
>>> url = code = fp = None
1451+
>>> hdrs = 'Content-Length: 42'
1452+
>>> err = urllib.error.HTTPError(url, code, msg, hdrs, fp)
14501453
>>> assert hasattr(err, 'reason')
14511454
>>> err.reason
14521455
'something bad happened'
1456+
>>> assert hasattr(err, 'hdrs')
1457+
>>> err.hdrs
1458+
'Content-Length: 42'
1459+
>>> expected_errmsg = 'HTTP Error %s: %s' % (err.code, err.msg)
1460+
>>> assert str(err) == expected_errmsg
14531461
"""
14541462

14551463
def test_HTTPError_interface_call(self):

0 commit comments

Comments
 (0)