summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_urllib2.py
diff options
context:
space:
mode:
authorSenthil Kumaran <orsenthil@gmail.com>2009-10-11 05:35:44 (GMT)
committerSenthil Kumaran <orsenthil@gmail.com>2009-10-11 05:35:44 (GMT)
commitdff2028a1b8d680cc489bb3ffb8a5b120e772c8a (patch)
tree278ee6ecc3b25c22122a05cc1d4b2d69f95d3072 /Lib/test/test_urllib2.py
parent1ab4095e763ab1924b0ab9fbe22bbe29514c1492 (diff)
downloadcpython-dff2028a1b8d680cc489bb3ffb8a5b120e772c8a.zip
cpython-dff2028a1b8d680cc489bb3ffb8a5b120e772c8a.tar.gz
cpython-dff2028a1b8d680cc489bb3ffb8a5b120e772c8a.tar.bz2
Merged revisions 75333 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r75333 | senthil.kumaran | 2009-10-11 07:30:07 +0530 (Sun, 11 Oct 2009) | 3 lines Fixed Issue6894, urllib2 doesn't respect "no_proxy" environment ........
Diffstat (limited to 'Lib/test/test_urllib2.py')
-rw-r--r--Lib/test/test_urllib2.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py
index b83eb46..6778293 100644
--- a/Lib/test/test_urllib2.py
+++ b/Lib/test/test_urllib2.py
@@ -943,6 +943,22 @@ class HandlerTests(unittest.TestCase):
self.assertEqual([(handlers[0], "http_open")],
[tup[0:2] for tup in o.calls])
+ def test_proxy_no_proxy(self):
+ os.environ['no_proxy'] = 'python.org'
+ o = OpenerDirector()
+ ph = urllib2.ProxyHandler(dict(http="proxy.example.com"))
+ o.add_handler(ph)
+ req = Request("http://www.perl.org/")
+ self.assertEqual(req.get_host(), "www.perl.org")
+ r = o.open(req)
+ self.assertEqual(req.get_host(), "proxy.example.com")
+ req = Request("http://www.python.org")
+ self.assertEqual(req.get_host(), "www.python.org")
+ r = o.open(req)
+ self.assertEqual(req.get_host(), "www.python.org")
+ del os.environ['no_proxy']
+
+
def test_proxy_https(self):
o = OpenerDirector()
ph = urllib2.ProxyHandler(dict(https='proxy.example.com:3128'))