Kaydet (Commit) 2c7470d9 authored tarafından Benjamin Peterson's avatar Benjamin Peterson

#3879 fix a regression in urllib.getproxies_environment

reviewers: Benjamin, Georg
üst 1672e10d
......@@ -94,6 +94,31 @@ class urlopen_FileTests(unittest.TestCase):
for line in self.returned_obj.__iter__():
self.assertEqual(line, self.text)
class ProxyTests(unittest.TestCase):
def setUp(self):
unittest.TestCase.setUp(self)
# Save all proxy related env vars
self._saved_environ = dict([(k, v) for k, v in os.environ.iteritems()
if k.lower().find('proxy') >= 0])
# Delete all proxy related env vars
for k in self._saved_environ:
del os.environ[k]
def tearDown(self):
unittest.TestCase.tearDown(self)
# Restore all proxy related env vars
for k, v in self._saved_environ:
os.environ[k] = v
def test_getproxies_environment_keep_no_proxies(self):
os.environ['NO_PROXY'] = 'localhost'
proxies = urllib.getproxies_environment()
# getproxies_environment use lowered case truncated (no '_proxy') keys
self.assertEquals('localhost', proxies['no'])
class urlopen_HttpTests(unittest.TestCase):
"""Test urlopen() opening a fake http connection."""
......@@ -648,6 +673,7 @@ def test_main():
urlopen_FileTests,
urlopen_HttpTests,
urlretrieve_FileTests,
ProxyTests,
QuotingTests,
UnquotingTests,
urlencode_Tests,
......
......@@ -1299,9 +1299,6 @@ def getproxies_environment():
proxies = {}
for name, value in os.environ.items():
name = name.lower()
if name == 'no_proxy':
# handled in proxy_bypass_environment
continue
if value and name[-6:] == '_proxy':
proxies[name[:-6]] = value
return proxies
......
......@@ -15,6 +15,8 @@ Core and Builtins
Library
-------
- Issue #3879: A regression in urllib.getproxies_enviroment was fixed.
Build
-----
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment