MCPcopy
hub / github.com/psf/requests / test_use_proxy_from_environment

Function test_use_proxy_from_environment

tests/test_lowlevel.py:290–305  ·  view source on GitHub ↗
(httpbin, var, scheme)

Source from the content-addressed store, hash-verified

288
289@pytest.mark.parametrize("var,scheme", _proxy_combos)
290def test_use_proxy_from_environment(httpbin, var, scheme):
291 url = f"{scheme}://httpbin.org"
292 fake_proxy = Server() # do nothing with the requests; just close the socket
293 with fake_proxy as (host, port):
294 proxy_url = f"socks5://{host}:{port}"
295 kwargs = {var: proxy_url}
296 with override_environ(**kwargs):
297 # fake proxy's lack of response will cause a ConnectionError
298 with pytest.raises(requests.exceptions.ConnectionError):
299 requests.get(url)
300
301 # the fake proxy received a request
302 assert len(fake_proxy.handler_results) == 1
303
304 # it had actual content (not checking for SOCKS protocol for now)
305 assert len(fake_proxy.handler_results[0]) > 0
306
307
308def test_redirect_rfc1808_to_non_ascii_location():

Callers

nothing calls this directly

Calls 3

ServerClass · 0.90
override_environFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected