summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_ensurepip.py
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2014-02-04 13:02:36 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2014-02-04 13:02:36 (GMT)
commit6edd82a1d25bb941ebb5f5e98690ddc2ddbbd79e (patch)
tree6388877441889873b89608d9e9542aba4ba7a3eb /Lib/test/test_ensurepip.py
parenta9b15241c6bdf8ac71f1dc598b7c01a20518b6a7 (diff)
downloadcpython-6edd82a1d25bb941ebb5f5e98690ddc2ddbbd79e.zip
cpython-6edd82a1d25bb941ebb5f5e98690ddc2ddbbd79e.tar.gz
cpython-6edd82a1d25bb941ebb5f5e98690ddc2ddbbd79e.tar.bz2
Close #20053: ignore default pip config settings
ensurepip now sets PIP_CONFIG_FILE to os.devnull before import pip from the wheel file. This also ensures venv ignores the default settings when bootstrapping pip.
Diffstat (limited to 'Lib/test/test_ensurepip.py')
-rw-r--r--Lib/test/test_ensurepip.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_ensurepip.py b/Lib/test/test_ensurepip.py
index 68dd3e2..6ddf8f6 100644
--- a/Lib/test/test_ensurepip.py
+++ b/Lib/test/test_ensurepip.py
@@ -36,9 +36,11 @@ class EnsurepipMixin:
self.addCleanup(run_pip_patch.stop)
# Avoid side effects on the actual os module
+ real_devnull = os.devnull
os_patch = unittest.mock.patch("ensurepip.os")
patched_os = os_patch.start()
self.addCleanup(os_patch.stop)
+ patched_os.devnull = real_devnull
patched_os.path = os.path
self.os_environ = patched_os.environ = os.environ.copy()
@@ -161,6 +163,12 @@ class TestBootstrap(EnsurepipMixin, unittest.TestCase):
ensurepip.bootstrap()
self.assertNotIn("PIP_THIS_SHOULD_GO_AWAY", self.os_environ)
+ @requires_usable_pip
+ def test_pip_config_file_disabled(self):
+ # ensurepip deliberately ignores the pip config file
+ # See http://bugs.python.org/issue20053 for details
+ ensurepip.bootstrap()
+ self.assertEqual(self.os_environ["PIP_CONFIG_FILE"], os.devnull)
@contextlib.contextmanager
def fake_pip(version=ensurepip._PIP_VERSION):
@@ -240,6 +248,14 @@ class TestUninstall(EnsurepipMixin, unittest.TestCase):
ensurepip._uninstall_helper()
self.assertNotIn("PIP_THIS_SHOULD_GO_AWAY", self.os_environ)
+ @requires_usable_pip
+ def test_pip_config_file_disabled(self):
+ # ensurepip deliberately ignores the pip config file
+ # See http://bugs.python.org/issue20053 for details
+ with fake_pip():
+ ensurepip._uninstall_helper()
+ self.assertEqual(self.os_environ["PIP_CONFIG_FILE"], os.devnull)
+
class TestMissingSSL(EnsurepipMixin, unittest.TestCase):