Skip to content

gh-160511: Ignore configured proxies in test_urllib.urlopen_HttpTests - #160512

Open
devdavidejesus wants to merge 1 commit into
python:mainfrom
devdavidejesus:fix-test-urllib-proxy
Open

devdavidejesus wants to merge 1 commit into
python:mainfrom
devdavidejesus:fix-test-urllib-proxy

Conversation

@devdavidejesus

@devdavidejesus devdavidejesus commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

urlopen_HttpTests.setUp() now replaces urllib.request.getproxies with one that returns no proxies, and resets the module-level opener before and after each test, so a proxy from the environment or the macOS system settings, or an opener built by an earlier test, no longer changes the result.

Test-only change, so no NEWS entry.

Tested with a pydebug build of main on macOS:

  • With https_proxy set (alone, or with http_proxy), -m test test_urllib fails without the change (2 errors) and passes with it.
  • It also passes with no proxy set, and -R 3:3 (with https_proxy set) reports no leaks.
  • test_urllib2 and test_urllib2_localnet pass.

See #160511.

…pTests

Two tests failed when https_proxy was set, because urlopen() then
tunnels through the proxy and the invalid host is rejected later with
ValueError (or URLError if the proxy is unreachable) instead of
InvalidURL. Make getproxies() return no proxies in these tests and
reset the cached opener.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant