Skip to content
Myr

Raise a ProxyError for proxy related connection issues.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Alexander Shchapov · committed by Alexander Shchapov · parent 190cddd · Browse files · 2 files+10 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+10 added−1 removed

  • tests:+7 added−1 removed
  • other:+3 added−0 removed

2 files+10 added−1 removed

modified:requests/adapters.py+3 added
432 unmodified lines
433434 if isinstance(e.reason, ResponseError):435 raise RetryError(e, request=request)436437 if isinstance(e.reason, _ProxyError):438 raise ProxyError(e, request=request)439440 raise ConnectionError(e, request=request)441442 except ClosedPoolError as e:443 raise ConnectionError(e, request=request)
13 unmodified lines
modified:tests/test_requests.py+7 added-1 removed
19 unmodified lines
20 builtin_str, OrderedDict)21from requests.cookies import cookiejar_from_dict, morsel_to_cookie22from requests.exceptions import (23 ConnectionError, ConnectTimeout, InvalidSchema, InvalidURL,24 MissingSchema, ReadTimeout, Timeout, RetryError, TooManyRedirects)24 MissingSchema, ReadTimeout, Timeout, RetryError, TooManyRedirects,25 ProxyError)26from requests.models import PreparedRequest27from requests.structures import CaseInsensitiveDict28from requests.sessions import SessionRedirectMixin29from requests.models import urlencode
285 unmodified lines
315 def test_errors(self, url, exception):316 with pytest.raises(exception):317 requests.get(url, timeout=1)318319 def test_proxy_error(self):320 # any proxy related error (address resolution, no route to host, etc) should result in a ProxyError321 with pytest.raises(ProxyError):322 requests.get('http://localhost:1', proxies={'http': 'non-resolvable-address'})323324 def test_basicauth_with_netrc(self, httpbin):325 auth = ('user', 'pass')326 wrong_auth = ('wronguser', 'wrongpass')327 url = httpbin('basic-auth', 'user', 'pass')
1165 unmodified lines