You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test_urllib: two urlopen_HttpTests tests fail when an HTTPS proxy is configured #160511
Two tests in test_urllib.urlopen_HttpTests fail when https_proxy (or HTTPS_PROXY) is set in the environment, as it often is behind a corporate proxy. http_proxy alone does not trigger it.
Both errors come from the https: half of each test, which expects http.client.InvalidURL from the host check in HTTPConnection.__init__(). With an HTTPS proxy, the connection is created for the proxy and the bad host is passed to set_tunnel(), so it is rejected later with a different error:
test_url_host_with_control_char_rejected: _tunnel() raises ValueError after connecting to the proxy. Here nothing listens on the proxy address, so the test gets URLError first.
test_url_host_with_newline_header_injection_rejected: putheader() raises ValueError for the Host header, before connecting.
The tests call urllib.request.urlopen(), whose default opener includes ProxyHandler(), so they depend on what getproxies() returns: the environment, or on macOS also the system proxy settings. The opener is also cached at module level: when the whole file runs, urlopen_FileTests has already built it with the proxies of that moment. ProxyTests in the same file already removes the proxy variables in setUp().
The tests pass when no proxy is set. The same tests and code are in 3.14 and 3.15.
Activity