[Python-checkins] cpython (3.5): Issue #28435: Avoid no_proxy environment variable interfering with tests

martin.panter python-checkins at python.org
Fri Oct 21 23:22:48 EDT 2016


https://hg.python.org/cpython/rev/dc9ad44125de
changeset:   104641:dc9ad44125de
branch:      3.5
parent:      104639:d76fccbad014
user:        Martin Panter <vadmium+py at gmail.com>
date:        Sat Oct 22 01:42:06 2016 +0000
summary:
  Issue #28435: Avoid no_proxy environment variable interfering with tests

Patch by Piotr Szczepaniak.

files:
  Lib/test/test_urllib2_localnet.py |  9 +++++++++
  Misc/ACKS                         |  1 +
  2 files changed, 10 insertions(+), 0 deletions(-)


diff --git a/Lib/test/test_urllib2_localnet.py b/Lib/test/test_urllib2_localnet.py
--- a/Lib/test/test_urllib2_localnet.py
+++ b/Lib/test/test_urllib2_localnet.py
@@ -323,6 +323,14 @@
 
     def setUp(self):
         super(ProxyAuthTests, self).setUp()
+        # Ignore proxy bypass settings in the environment.
+        def restore_environ(old_environ):
+            os.environ.clear()
+            os.environ.update(old_environ)
+        self.addCleanup(restore_environ, os.environ.copy())
+        os.environ['NO_PROXY'] = ''
+        os.environ['no_proxy'] = ''
+
         self.digest_auth_handler = DigestAuthHandler()
         self.digest_auth_handler.set_users({self.USER: self.PASSWD})
         self.digest_auth_handler.set_realm(self.REALM)
@@ -445,6 +453,7 @@
             os.environ.update(old_environ)
         self.addCleanup(restore_environ, os.environ.copy())
         os.environ['NO_PROXY'] = '*'
+        os.environ['no_proxy'] = '*'
 
     def urlopen(self, url, data=None, **kwargs):
         l = []
diff --git a/Misc/ACKS b/Misc/ACKS
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -1450,6 +1450,7 @@
 Thenault Sylvain
 Péter Szabó
 John Szakmeister
+Piotr Szczepaniak
 Amir Szekely
 Maciej Szulik
 Arfrever Frehtes Taifersar Arahesis

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list