From ff96b2ae14b1efdfc01e202a03e5d464fdedfc87 Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Sat, 3 Jan 2009 22:55:38 +0000 Subject: test_urllib would set environment variable NO_PROXY without removing it afterwards. --- Lib/test/test_urllib.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py index 6568732..a46f421 100644 --- a/Lib/test/test_urllib.py +++ b/Lib/test/test_urllib.py @@ -130,10 +130,14 @@ class ProxyTests(unittest.TestCase): os.environ[k] = v def test_getproxies_environment_keep_no_proxies(self): - os.environ['NO_PROXY'] = 'localhost' - proxies = urllib.request.getproxies_environment() - # getproxies_environment use lowered case truncated (no '_proxy') keys - self.assertEquals('localhost', proxies['no']) + 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'] class urlopen_HttpTests(unittest.TestCase): -- cgit v0.12