Skip to content

Commit 854383e

Browse files
committed
fix: urllib2 with proxy tests maybe fail on macOS
Signed-off-by: yihong0618 <[email protected]>
1 parent 6e2b9a2 commit 854383e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Lib/test/test_urllib2_localnet.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,12 @@ def create_fake_proxy_handler(*args, **kwargs):
351351
self.server.start()
352352
self.server.ready.wait()
353353
proxy_url = "http://127.0.0.1:%d" % self.server.port
354+
355+
# Set http_proxy environment variable to override system proxy settings
356+
# This ensures the proxy is used even on macOS where localhost is
357+
# typically in the proxy bypass list
358+
os.environ['http_proxy'] = proxy_url
359+
354360
handler = urllib.request.ProxyHandler({"http" : proxy_url})
355361
self.proxy_digest_handler = urllib.request.ProxyDigestAuthHandler()
356362
self.opener = urllib.request.build_opener(

0 commit comments

Comments
 (0)