(httpbin, var, scheme)
| 288 | |
| 289 | @pytest.mark.parametrize("var,scheme", _proxy_combos) |
| 290 | def 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 | |
| 308 | def test_redirect_rfc1808_to_non_ascii_location(): |
nothing calls this directly
no test coverage detected