|
23 | 23 | cookiejar_from_dict, morsel_to_cookie)
|
24 | 24 | from requests.exceptions import (
|
25 | 25 | ConnectionError, ConnectTimeout, InvalidSchema, InvalidURL,
|
26 |
| - MissingSchema, ReadTimeout, Timeout, RetryError, TooManyRedirects, |
| 26 | + MissingSchema, ReadTimeout, Timeout, RetryError, RequestException, TooManyRedirects, |
27 | 27 | ProxyError, InvalidHeader, UnrewindableBodyError, SSLError, InvalidProxyURL, InvalidJSONError)
|
28 | 28 | from requests.models import PreparedRequest
|
29 | 29 | from requests.structures import CaseInsensitiveDict
|
30 | 30 | from requests.sessions import SessionRedirectMixin
|
31 | 31 | from requests.models import urlencode
|
32 | 32 | from requests.hooks import default_hooks
|
33 |
| -from requests.compat import MutableMapping |
| 33 | +from requests.compat import JSONDecodeError, is_py3, MutableMapping |
34 | 34 |
|
35 | 35 | from .compat import StringIO, u
|
36 | 36 | from .utils import override_environ
|
@@ -2585,5 +2585,11 @@ def test_post_json_nan(self, httpbin):
|
2585 | 2585 |
|
2586 | 2586 | def test_json_decode_compatibility(self, httpbin):
|
2587 | 2587 | r = requests.get(httpbin('bytes/20'))
|
2588 |
| - with pytest.raises(requests.exceptions.JSONDecodeError): |
| 2588 | + data = r.text |
| 2589 | + with pytest.raises(requests.exceptions.JSONDecodeError) as excinfo: |
2589 | 2590 | r.json()
|
| 2591 | + assert isinstance(excinfo.value, RequestException) |
| 2592 | + assert isinstance(excinfo.value, JSONDecodeError) |
| 2593 | + assert data not in str(excinfo.value) |
| 2594 | + if is_py3: |
| 2595 | + assert excinfo.value.doc == data |
0 commit comments