Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ff96b2a

Browse files
committed
test_urllib would set environment variable NO_PROXY without removing it afterwards.
1 parent 3de5a08 commit ff96b2a

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

Lib/test/test_urllib.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,14 @@ def tearDown(self):
130130
os.environ[k] = v
131131

132132
def test_getproxies_environment_keep_no_proxies(self):
133-
os.environ['NO_PROXY'] = 'localhost'
134-
proxies = urllib.request.getproxies_environment()
135-
# getproxies_environment use lowered case truncated (no '_proxy') keys
136-
self.assertEquals('localhost', proxies['no'])
133+
try:
134+
os.environ['NO_PROXY'] = 'localhost'
135+
proxies = urllib.request.getproxies_environment()
136+
# getproxies_environment use lowered case truncated (no '_proxy') keys
137+
self.assertEquals('localhost', proxies['no'])
138+
finally:
139+
# The old value will be restored by tearDown, if applicable.
140+
del os.environ['NO_PROXY']
137141

138142

139143
class urlopen_HttpTests(unittest.TestCase):

0 commit comments

Comments
 (0)