requests icon indicating copy to clipboard operation
requests copied to clipboard

Allow tests to run if HTTP proxy env variables are already present,

Open ogayot opened this issue 3 years ago • 0 comments
trafficstars

Hello,

The following tests fail if HTTP proxy environment variables are already set:

FAILED tests/test_requests.py::TestRequests::test_mixed_case_scheme_acceptable
FAILED tests/test_requests.py::TestRequests::test_HTTP_302_ALLOW_REDIRECT_GET
FAILED tests/test_requests.py::TestRequests::test_errors[http://doesnotexist.google.com-ConnectionError]
FAILED tests/test_requests.py::TestRequests::test_respect_proxy_env_on_send_self_prepared_request
FAILED tests/test_requests.py::TestRequests::test_respect_proxy_env_on_send_session_prepared_request
FAILED tests/test_requests.py::TestRequests::test_respect_proxy_env_on_send_with_redirects
FAILED tests/test_requests.py::TestRequests::test_respect_proxy_env_on_get - ...
FAILED tests/test_requests.py::TestRequests::test_respect_proxy_env_on_request

The variables affecting the tests are:

  • http_proxy (and https_proxy potentially)
  • no_proxy

Fixed by overriding their value if they are already present in the environment.

The override_environ function would fail if attempting to delete a variable that is not in the environment. Added a suppress(KeyError) construct around the del instruction to fix it.

Thanks, Oilvier

ogayot avatar May 19 '22 16:05 ogayot