summaryrefslogtreecommitdiff
path: root/test/test_proxymanager.py
diff options
context:
space:
mode:
authorhodbn <hodbn@users.noreply.github.com>2020-04-03 06:22:00 -0700
committerGitHub <noreply@github.com>2020-04-03 08:22:00 -0500
commit84073f9a469669dc98aa03ca084c12aded9d6ba8 (patch)
tree1188b226e06a26e0bd119fd409e7234bfc4d06e1 /test/test_proxymanager.py
parent29b214a129883301f91ae4a74fd7ef2958cbf7b0 (diff)
downloadurllib3-84073f9a469669dc98aa03ca084c12aded9d6ba8.tar.gz
Unwrap ProxyError when evaluating retries (#1830)
Diffstat (limited to 'test/test_proxymanager.py')
-rw-r--r--test/test_proxymanager.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/test_proxymanager.py b/test/test_proxymanager.py
index fb947dae..3b1e1191 100644
--- a/test/test_proxymanager.py
+++ b/test/test_proxymanager.py
@@ -1,7 +1,14 @@
import pytest
+from .port_helpers import find_unused_port
from urllib3.poolmanager import ProxyManager
from urllib3.util.url import parse_url
+from urllib3.util.retry import Retry
+from urllib3.exceptions import (
+ MaxRetryError,
+ ProxyError,
+ NewConnectionError,
+)
class TestProxyManager(object):
@@ -57,3 +64,17 @@ class TestProxyManager(object):
with ProxyManager("https://proxy:8080") as p:
assert p._proxy_requires_url_absolute_form(http_url)
assert p._proxy_requires_url_absolute_form(https_url)
+
+ def test_proxy_connect_retry(self):
+ retry = Retry(total=None, connect=False)
+ with find_unused_port() as port:
+ with ProxyManager("http://localhost:{}".format(port)) as p:
+ with pytest.raises(ProxyError) as ei:
+ p.urlopen("HEAD", url="http://localhost/", retries=retry)
+ assert isinstance(ei.value.original_error, NewConnectionError)
+
+ retry = Retry(total=None, connect=2)
+ with ProxyManager("http://localhost:{}".format(port)) as p:
+ with pytest.raises(MaxRetryError) as ei:
+ p.urlopen("HEAD", url="http://localhost/", retries=retry)
+ assert isinstance(ei.value.reason.original_error, NewConnectionError)