summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2013-12-23 07:39:12 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2013-12-23 07:39:12 (GMT)
commited9af52ff064663f8ed2f40191b144a2b6a9865b (patch)
tree9ee2f95c0e453e14283c85e157d1d8445e67bb85 /Lib/test
parent6256fcbc97e0b1a1e0df1972221232b3a78dff18 (diff)
downloadcpython-ed9af52ff064663f8ed2f40191b144a2b6a9865b.zip
cpython-ed9af52ff064663f8ed2f40191b144a2b6a9865b.tar.gz
cpython-ed9af52ff064663f8ed2f40191b144a2b6a9865b.tar.bz2
Issue #19734: ignore pip env vars in ensurepip._uninstall
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_ensurepip.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_ensurepip.py b/Lib/test/test_ensurepip.py
index 8c125bf..2080ef1 100644
--- a/Lib/test/test_ensurepip.py
+++ b/Lib/test/test_ensurepip.py
@@ -160,6 +160,13 @@ class TestUninstall(unittest.TestCase):
self.run_pip = run_pip_patch.start()
self.addCleanup(run_pip_patch.stop)
+ # Avoid side effects on the actual os module
+ os_patch = unittest.mock.patch("ensurepip.os")
+ patched_os = os_patch.start()
+ self.addCleanup(os_patch.stop)
+ patched_os.path = os.path
+ self.os_environ = patched_os.environ = os.environ.copy()
+
def test_uninstall_skipped_when_not_installed(self):
with fake_pip(None):
ensurepip._uninstall()
@@ -204,6 +211,13 @@ class TestUninstall(unittest.TestCase):
["uninstall", "-y", "-vvv", "pip", "setuptools"]
)
+ def test_pip_environment_variables_removed(self):
+ # ensurepip deliberately ignores all pip environment variables
+ # See http://bugs.python.org/issue19734 for details
+ self.os_environ["PIP_THIS_SHOULD_GO_AWAY"] = "test fodder"
+ with fake_pip():
+ ensurepip._uninstall()
+ self.assertNotIn("PIP_THIS_SHOULD_GO_AWAY", self.os_environ)