summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_urllib.py
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2009-04-26 21:39:21 (GMT)
committerWalter Dörwald <walter@livinglogic.de>2009-04-26 21:39:21 (GMT)
commitb525e18500885731f958bd4a0114f26cea336500 (patch)
treef7ac3daec3d7e870dac64abe27c9166269a124c7 /Lib/test/test_urllib.py
parent4af362905cb1e8cb56e26a51021de855798227ea (diff)
downloadcpython-b525e18500885731f958bd4a0114f26cea336500.zip
cpython-b525e18500885731f958bd4a0114f26cea336500.tar.gz
cpython-b525e18500885731f958bd4a0114f26cea336500.tar.bz2
Merged revisions 71984 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r71984 | walter.doerwald | 2009-04-26 22:51:44 +0200 (So, 26 Apr 2009) | 2 lines Use test.test_support.EnvironmentVarGuard where tests change environment vars. ........
Diffstat (limited to 'Lib/test/test_urllib.py')
-rw-r--r--Lib/test/test_urllib.py24
1 files changed, 8 insertions, 16 deletions
diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py
index c16f30d..d616eb1 100644
--- a/Lib/test/test_urllib.py
+++ b/Lib/test/test_urllib.py
@@ -117,27 +117,19 @@ class urlopen_FileTests(unittest.TestCase):
class ProxyTests(unittest.TestCase):
def setUp(self):
- # Save all proxy related env vars
- self._saved_environ = dict([(k, v) for k, v in os.environ.items()
- if k.lower().find('proxy') >= 0])
- # Delete all proxy related env vars
- for k in self._saved_environ:
- del os.environ[k]
+ # Records changes to env vars
+ self.env = support.EnvironmentVarGuard()
def tearDown(self):
# Restore all proxy related env vars
- for k, v in self._saved_environ.items():
- os.environ[k] = v
+ self.env.__exit__()
+ del self.env
def test_getproxies_environment_keep_no_proxies(self):
- try:
- os.environ['NO_PROXY'] = 'localhost'
- proxies = urllib.request.getproxies_environment()
- # getproxies_environment use lowered case truncated (no '_proxy') keys
- self.assertEquals('localhost', proxies['no'])
- finally:
- # The old value will be restored by tearDown, if applicable.
- del os.environ['NO_PROXY']
+ self.env.set('NO_PROXY', 'localhost')
+ proxies = urllib.request.getproxies_environment()
+ # getproxies_environment use lowered case truncated (no '_proxy') keys
+ self.assertEquals('localhost', proxies['no'])
class urlopen_HttpTests(unittest.TestCase):