예제 #1
0
 def test_proxy_conn_fail(self):
     host, port = get_unreachable_address()
     http = proxy_from_url('http://%s:%s/' % (host, port))
     self.assertRaises(ProxyError, http.request, 'GET',
                       '%s/' % self.https_url)
     self.assertRaises(ProxyError, http.request, 'GET',
                       '%s/' % self.http_url)
예제 #2
0
 def test_connection_refused(self):
     # Does the pool retry if there is no listener on the port?
     host, port = get_unreachable_address()
     http = HTTPConnectionPool(host, port, maxsize=3, block=True)
     self.addCleanup(http.close)
     self.assertRaises(MaxRetryError, http.request, 'GET', '/', retries=0, release_conn=False)
     self.assertEqual(http.pool.qsize(), http.pool.maxsize)
예제 #3
0
 def test_connection_refused(self):
     # Does the pool retry if there is no listener on the port?
     host, port = get_unreachable_address()
     http = HTTPConnectionPool(host, port, maxsize=3, block=True)
     self.addCleanup(http.close)
     self.assertRaises(MaxRetryError, http.request, 'GET', '/', retries=0, release_conn=False)
     self.assertEqual(http.pool.qsize(), http.pool.maxsize)
예제 #4
0
 def test_proxy_conn_fail(self):
     host, port = get_unreachable_address()
     http = proxy_from_url('http://%s:%s/' % (host, port))
     self.assertRaises(ProxyError, http.request, 'GET',
                       '%s/' % self.https_url)
     self.assertRaises(ProxyError, http.request, 'GET',
                       '%s/' % self.http_url)
예제 #5
0
    def test_proxy_conn_fail(self):
        host, port = get_unreachable_address()
        http = proxy_from_url("http://%s:%s/" % (host, port), retries=1, timeout=0.05)
        self.addCleanup(http.clear)
        self.assertRaises(MaxRetryError, http.request, "GET", "%s/" % self.https_url)
        self.assertRaises(MaxRetryError, http.request, "GET", "%s/" % self.http_url)

        try:
            http.request("GET", "%s/" % self.http_url)
            self.fail("Failed to raise retry error.")
        except MaxRetryError as e:
            self.assertEqual(type(e.reason), ProxyError)
예제 #6
0
    def test_proxy_conn_fail(self):
        host, port = get_unreachable_address()
        http = proxy_from_url('http://%s:%s/' % (host, port), retries=1, timeout=0.05)
        self.assertRaises(MaxRetryError, http.request, 'GET',
                          '%s/' % self.https_url)
        self.assertRaises(MaxRetryError, http.request, 'GET',
                          '%s/' % self.http_url)

        try:
            http.request('GET', '%s/' % self.http_url)
            self.fail("Failed to raise retry error.")
        except MaxRetryError as e:
            self.assertEqual(type(e.reason), ProxyError)
예제 #7
0
    def test_proxy_conn_fail(self):
        host, port = get_unreachable_address()
        with proxy_from_url(f"http://{host}:{port}/",
                            retries=1,
                            timeout=LONG_TIMEOUT) as http:
            with pytest.raises(MaxRetryError):
                http.request("GET", f"{self.https_url}/")
            with pytest.raises(MaxRetryError):
                http.request("GET", f"{self.http_url}/")

            with pytest.raises(MaxRetryError) as e:
                http.request("GET", f"{self.http_url}/")
            assert type(e.value.reason) == ProxyError
예제 #8
0
    def test_proxy_conn_fail(self):
        host, port = get_unreachable_address()
        http = proxy_from_url('http://%s:%s/' % (host, port), retries=1)
        self.assertRaises(MaxRetryError, http.request, 'GET',
                          '%s/' % self.https_url)
        self.assertRaises(MaxRetryError, http.request, 'GET',
                          '%s/' % self.http_url)

        try:
            http.request('GET', '%s/' % self.http_url)
            self.fail("Failed to raise retry error.")
        except MaxRetryError as e:
            self.assertEqual(type(e.reason), ProxyError)
예제 #9
0
    def test_proxy_conn_fail(self):
        host, port = get_unreachable_address()
        with proxy_from_url("http://%s:%s/" % (host, port),
                            retries=1,
                            timeout=0.05) as http:
            with pytest.raises(MaxRetryError):
                http.request("GET", "%s/" % self.https_url)
            with pytest.raises(MaxRetryError):
                http.request("GET", "%s/" % self.http_url)

            try:
                http.request("GET", "%s/" % self.http_url)
                self.fail("Failed to raise retry error.")
            except MaxRetryError as e:
                assert type(e.reason) == ProxyError
    def test_proxy_conn_fail_from_dns(self, proxy_scheme: str,
                                      target_scheme: str) -> None:
        host, port = get_unreachable_address()
        with proxy_from_url(f"{proxy_scheme}://{host}:{port}/",
                            retries=1,
                            timeout=LONG_TIMEOUT) as http:
            if target_scheme == "https":
                target_url = self.https_url
            else:
                target_url = self.http_url

            with pytest.raises(MaxRetryError) as e:
                http.request("GET", f"{target_url}/")
            assert type(e.value.reason) == ProxyError
            assert (type(e.value.reason.original_error) ==
                    urllib3.exceptions.NameResolutionError)
예제 #11
0
 def test_connection_refused(self):
     # Does the pool retry if there is no listener on the port?
     host, port = get_unreachable_address()
     pool = HTTPConnectionPool(host, port)
     self.assertRaises(MaxRetryError, pool.request, 'GET', '/', retries=0)
예제 #12
0
 def test_connection_refused(self):
     # Does the pool retry if there is no listener on the port?
     host, port = get_unreachable_address()
     pool = HTTPConnectionPool(host, port)
     self.assertRaises(MaxRetryError, pool.request, 'GET', '/', retries=0)