From 2e70a0e44bb8f51e97b1c611d15d4e7d69791602 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Mon, 14 Mar 2011 14:05:14 +1300 Subject: [PATCH] Fix unit tests on OSX when a system proxy is configured. --- test/test_server.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/test/test_server.py b/test/test_server.py index 3559248ee..e9b611657 100644 --- a/test/test_server.py +++ b/test/test_server.py @@ -7,23 +7,26 @@ class uSanity(tutils.ProxTest): """ Just check that the HTTP server is running. """ - f = urllib.urlopen("http://127.0.0.1:%s"%tutils.HTTP_PORT) + f = urllib.urlopen("http://127.0.0.1:%s"%tutils.HTTP_PORT, proxies={}) assert f.read() def test_https(self): """ Just check that the HTTPS server is running. """ - f = urllib.urlopen("https://127.0.0.1:%s"%tutils.HTTPS_PORT) + f = urllib.urlopen("https://127.0.0.1:%s"%tutils.HTTPS_PORT, proxies={}) assert f.read() class uProxy(tutils.ProxTest): HOST = "127.0.0.1" def _get(self, host=HOST): + proxy_support = urllib2.ProxyHandler( + {"http" : "http://127.0.0.1:%s"%tutils.PROXL_PORT} + ) + opener = urllib2.build_opener(proxy_support) r = urllib2.Request("http://%s:%s"%(host, tutils.HTTP_PORT)) - r.set_proxy("127.0.0.1:%s"%tutils.PROXL_PORT, "http") - return urllib2.urlopen(r) + return opener.open(r) def _sget(self, host=HOST): proxy_support = urllib2.ProxyHandler(