Issue 13211 reveals that HTTPError didn't implement the URLError interface even though HTTPError is a subclass of URLError.
(self)
| 1915 | self.opener_has_handler(o, MyOtherHTTPHandler) |
| 1916 | |
| 1917 | def test_HTTPError_interface(self): |
| 1918 | """ |
| 1919 | Issue 13211 reveals that HTTPError didn't implement the URLError |
| 1920 | interface even though HTTPError is a subclass of URLError. |
| 1921 | """ |
| 1922 | msg = 'something bad happened' |
| 1923 | url = code = fp = None |
| 1924 | hdrs = 'Content-Length: 42' |
| 1925 | err = urllib.error.HTTPError(url, code, msg, hdrs, fp) |
| 1926 | self.assertHasAttr(err, 'reason') |
| 1927 | self.assertEqual(err.reason, 'something bad happened') |
| 1928 | self.assertHasAttr(err, 'headers') |
| 1929 | self.assertEqual(err.headers, 'Content-Length: 42') |
| 1930 | expected_errmsg = 'HTTP Error %s: %s' % (err.code, err.msg) |
| 1931 | self.assertEqual(str(err), expected_errmsg) |
| 1932 | expected_errmsg = '<HTTPError %s: %r>' % (err.code, err.msg) |
| 1933 | self.assertEqual(repr(err), expected_errmsg) |
| 1934 | err.close() |
| 1935 | |
| 1936 | def test_gh_98778(self): |
| 1937 | x = urllib.error.HTTPError("url", 405, "METHOD NOT ALLOWED", None, None) |
nothing calls this directly
no test coverage detected