mirror of
https://github.com/python/cpython.git
synced 2025-07-25 12:14:38 +00:00
[3.13] gh-127591: Fix altering environment in test_urllib2 (unsetting no_proxy) (GH-132584) (GH-132585)
(cherry picked from commit 8b7cb947c5
)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
08faa2aeac
commit
8128bcfa08
1 changed files with 4 additions and 4 deletions
|
@ -1432,7 +1432,8 @@ class HandlerTests(unittest.TestCase):
|
||||||
[tup[0:2] for tup in o.calls])
|
[tup[0:2] for tup in o.calls])
|
||||||
|
|
||||||
def test_proxy_no_proxy(self):
|
def test_proxy_no_proxy(self):
|
||||||
os.environ['no_proxy'] = 'python.org'
|
env = self.enterContext(os_helper.EnvironmentVarGuard())
|
||||||
|
env['no_proxy'] = 'python.org'
|
||||||
o = OpenerDirector()
|
o = OpenerDirector()
|
||||||
ph = urllib.request.ProxyHandler(dict(http="proxy.example.com"))
|
ph = urllib.request.ProxyHandler(dict(http="proxy.example.com"))
|
||||||
o.add_handler(ph)
|
o.add_handler(ph)
|
||||||
|
@ -1444,10 +1445,10 @@ class HandlerTests(unittest.TestCase):
|
||||||
self.assertEqual(req.host, "www.python.org")
|
self.assertEqual(req.host, "www.python.org")
|
||||||
o.open(req)
|
o.open(req)
|
||||||
self.assertEqual(req.host, "www.python.org")
|
self.assertEqual(req.host, "www.python.org")
|
||||||
del os.environ['no_proxy']
|
|
||||||
|
|
||||||
def test_proxy_no_proxy_all(self):
|
def test_proxy_no_proxy_all(self):
|
||||||
os.environ['no_proxy'] = '*'
|
env = self.enterContext(os_helper.EnvironmentVarGuard())
|
||||||
|
env['no_proxy'] = '*'
|
||||||
o = OpenerDirector()
|
o = OpenerDirector()
|
||||||
ph = urllib.request.ProxyHandler(dict(http="proxy.example.com"))
|
ph = urllib.request.ProxyHandler(dict(http="proxy.example.com"))
|
||||||
o.add_handler(ph)
|
o.add_handler(ph)
|
||||||
|
@ -1455,7 +1456,6 @@ class HandlerTests(unittest.TestCase):
|
||||||
self.assertEqual(req.host, "www.python.org")
|
self.assertEqual(req.host, "www.python.org")
|
||||||
o.open(req)
|
o.open(req)
|
||||||
self.assertEqual(req.host, "www.python.org")
|
self.assertEqual(req.host, "www.python.org")
|
||||||
del os.environ['no_proxy']
|
|
||||||
|
|
||||||
def test_proxy_https(self):
|
def test_proxy_https(self):
|
||||||
o = OpenerDirector()
|
o = OpenerDirector()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue