diff options
author | Benjamin Peterson <benjamin@python.org> | 2008-09-21 21:27:51 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2008-09-21 21:27:51 (GMT) |
commit | 2c7470d9513461aaf1af4e655c580d1ece602d2f (patch) | |
tree | a3428415965a59a0a146c9ad9be9de60675c3021 /Lib | |
parent | 1672e10dc2d7b70ee1830fbe0294e81f25560387 (diff) | |
download | cpython-2c7470d9513461aaf1af4e655c580d1ece602d2f.zip cpython-2c7470d9513461aaf1af4e655c580d1ece602d2f.tar.gz cpython-2c7470d9513461aaf1af4e655c580d1ece602d2f.tar.bz2 |
#3879 fix a regression in urllib.getproxies_environment
reviewers: Benjamin, Georg
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_urllib.py | 26 | ||||
-rw-r--r-- | Lib/urllib.py | 3 |
2 files changed, 26 insertions, 3 deletions
diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py index 7b351b8..b78f30a 100644 --- a/Lib/test/test_urllib.py +++ b/Lib/test/test_urllib.py @@ -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, diff --git a/Lib/urllib.py b/Lib/urllib.py index 55a29f4..38c5ee4 100644 --- a/Lib/urllib.py +++ b/Lib/urllib.py @@ -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 |