MCPcopy Index your code
hub / github.com/python/cpython / test_HTTPError_interface

Method test_HTTPError_interface

Lib/test/test_urllib2.py:1917–1934  ·  view source on GitHub ↗

Issue 13211 reveals that HTTPError didn't implement the URLError interface even though HTTPError is a subclass of URLError.

(self)

Source from the content-addressed store, hash-verified

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)

Callers

nothing calls this directly

Calls 4

strFunction · 0.85
assertHasAttrMethod · 0.80
assertEqualMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected