[Python-checkins] cpython (2.7): pip 9.0 works fine without the ssl module
donald.stufft
python-checkins at python.org
Wed Nov 2 16:20:26 EDT 2016
https://hg.python.org/cpython/rev/c0a0abce38f2
changeset: 104883:c0a0abce38f2
branch: 2.7
user: Donald Stufft <donald at stufft.io>
date: Wed Nov 02 16:20:20 2016 -0400
summary:
pip 9.0 works fine without the ssl module
files:
Lib/ensurepip/__init__.py | 21 -------
Lib/test/test_ensurepip.py | 69 --------------------------
2 files changed, 0 insertions(+), 90 deletions(-)
diff --git a/Lib/ensurepip/__init__.py b/Lib/ensurepip/__init__.py
--- a/Lib/ensurepip/__init__.py
+++ b/Lib/ensurepip/__init__.py
@@ -16,20 +16,6 @@
_PIP_VERSION = "9.0.0"
-# pip currently requires ssl support, so we try to provide a nicer
-# error message when that is missing (http://bugs.python.org/issue19744)
-_MISSING_SSL_MESSAGE = ("pip {} requires SSL/TLS".format(_PIP_VERSION))
-try:
- import ssl
-except ImportError:
- ssl = None
-
- def _require_ssl_for_pip():
- raise RuntimeError(_MISSING_SSL_MESSAGE)
-else:
- def _require_ssl_for_pip():
- pass
-
_PROJECTS = [
("setuptools", _SETUPTOOLS_VERSION),
("pip", _PIP_VERSION),
@@ -77,7 +63,6 @@
if altinstall and default_pip:
raise ValueError("Cannot use altinstall and default_pip together")
- _require_ssl_for_pip()
_disable_pip_configuration_settings()
# By default, installing pip and setuptools installs all of the
@@ -143,7 +128,6 @@
print(msg.format(pip.__version__, _PIP_VERSION), file=sys.stderr)
return
- _require_ssl_for_pip()
_disable_pip_configuration_settings()
# Construct the arguments to be passed to the pip command
@@ -155,11 +139,6 @@
def _main(argv=None):
- if ssl is None:
- print("Ignoring ensurepip failure: {}".format(_MISSING_SSL_MESSAGE),
- file=sys.stderr)
- return
-
import argparse
parser = argparse.ArgumentParser(prog="python -m ensurepip")
parser.add_argument(
diff --git a/Lib/test/test_ensurepip.py b/Lib/test/test_ensurepip.py
--- a/Lib/test/test_ensurepip.py
+++ b/Lib/test/test_ensurepip.py
@@ -9,22 +9,6 @@
import ensurepip
import ensurepip._uninstall
-# pip currently requires ssl support, so we ensure we handle
-# it being missing (http://bugs.python.org/issue19744)
-ensurepip_no_ssl = test.test_support.import_fresh_module("ensurepip",
- blocked=["ssl"])
-try:
- import ssl
-except ImportError:
- ssl = None
-
- def requires_usable_pip(f):
- deco = unittest.skip(ensurepip._MISSING_SSL_MESSAGE)
- return deco(f)
-else:
- def requires_usable_pip(f):
- return f
-
class TestEnsurePipVersion(unittest.TestCase):
@@ -51,7 +35,6 @@
class TestBootstrap(EnsurepipMixin, unittest.TestCase):
- @requires_usable_pip
def test_basic_bootstrapping(self):
ensurepip.bootstrap()
@@ -66,7 +49,6 @@
additional_paths = self.run_pip.call_args[0][1]
self.assertEqual(len(additional_paths), 2)
- @requires_usable_pip
def test_bootstrapping_with_root(self):
ensurepip.bootstrap(root="/foo/bar/")
@@ -79,7 +61,6 @@
mock.ANY,
)
- @requires_usable_pip
def test_bootstrapping_with_user(self):
ensurepip.bootstrap(user=True)
@@ -91,7 +72,6 @@
mock.ANY,
)
- @requires_usable_pip
def test_bootstrapping_with_upgrade(self):
ensurepip.bootstrap(upgrade=True)
@@ -103,7 +83,6 @@
mock.ANY,
)
- @requires_usable_pip
def test_bootstrapping_with_verbosity_1(self):
ensurepip.bootstrap(verbosity=1)
@@ -115,7 +94,6 @@
mock.ANY,
)
- @requires_usable_pip
def test_bootstrapping_with_verbosity_2(self):
ensurepip.bootstrap(verbosity=2)
@@ -127,7 +105,6 @@
mock.ANY,
)
- @requires_usable_pip
def test_bootstrapping_with_verbosity_3(self):
ensurepip.bootstrap(verbosity=3)
@@ -139,17 +116,14 @@
mock.ANY,
)
- @requires_usable_pip
def test_bootstrapping_with_regular_install(self):
ensurepip.bootstrap()
self.assertEqual(self.os_environ["ENSUREPIP_OPTIONS"], "install")
- @requires_usable_pip
def test_bootstrapping_with_alt_install(self):
ensurepip.bootstrap(altinstall=True)
self.assertEqual(self.os_environ["ENSUREPIP_OPTIONS"], "altinstall")
- @requires_usable_pip
def test_bootstrapping_with_default_pip(self):
ensurepip.bootstrap(default_pip=True)
self.assertNotIn("ENSUREPIP_OPTIONS", self.os_environ)
@@ -159,7 +133,6 @@
ensurepip.bootstrap(altinstall=True, default_pip=True)
self.assertFalse(self.run_pip.called)
- @requires_usable_pip
def test_pip_environment_variables_removed(self):
# ensurepip deliberately ignores all pip environment variables
# See http://bugs.python.org/issue19734 for details
@@ -167,7 +140,6 @@
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
@@ -210,7 +182,6 @@
self.assertIn("only uninstall a matching version", warning)
self.assertFalse(self.run_pip.called)
- @requires_usable_pip
def test_uninstall(self):
with fake_pip():
ensurepip._uninstall_helper()
@@ -222,7 +193,6 @@
]
)
- @requires_usable_pip
def test_uninstall_with_verbosity_1(self):
with fake_pip():
ensurepip._uninstall_helper(verbosity=1)
@@ -234,7 +204,6 @@
]
)
- @requires_usable_pip
def test_uninstall_with_verbosity_2(self):
with fake_pip():
ensurepip._uninstall_helper(verbosity=2)
@@ -246,7 +215,6 @@
]
)
- @requires_usable_pip
def test_uninstall_with_verbosity_3(self):
with fake_pip():
ensurepip._uninstall_helper(verbosity=3)
@@ -258,7 +226,6 @@
]
)
- @requires_usable_pip
def test_pip_environment_variables_removed(self):
# ensurepip deliberately ignores all pip environment variables
# See http://bugs.python.org/issue19734 for details
@@ -267,7 +234,6 @@
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
@@ -276,38 +242,6 @@
self.assertEqual(self.os_environ["PIP_CONFIG_FILE"], os.devnull)
-class TestMissingSSL(EnsurepipMixin, unittest.TestCase):
-
- def setUp(self):
- sys.modules["ensurepip"] = ensurepip_no_ssl
-
- @self.addCleanup
- def restore_module():
- sys.modules["ensurepip"] = ensurepip
- super(TestMissingSSL, self).setUp()
-
- def test_bootstrap_requires_ssl(self):
- self.os_environ["PIP_THIS_SHOULD_STAY"] = "test fodder"
- with self.assertRaisesRegexp(RuntimeError, "requires SSL/TLS"):
- ensurepip_no_ssl.bootstrap()
- self.assertFalse(self.run_pip.called)
- self.assertIn("PIP_THIS_SHOULD_STAY", self.os_environ)
-
- def test_uninstall_requires_ssl(self):
- self.os_environ["PIP_THIS_SHOULD_STAY"] = "test fodder"
- with self.assertRaisesRegexp(RuntimeError, "requires SSL/TLS"):
- with fake_pip():
- ensurepip_no_ssl._uninstall_helper()
- self.assertFalse(self.run_pip.called)
- self.assertIn("PIP_THIS_SHOULD_STAY", self.os_environ)
-
- def test_main_exits_early_with_warning(self):
- with test.test_support.captured_stderr() as stderr:
- ensurepip_no_ssl._main(["--version"])
- warning = stderr.getvalue().strip()
- self.assertTrue(warning.endswith("requires SSL/TLS"), warning)
- self.assertFalse(self.run_pip.called)
-
# Basic testing of the main functions and their argument parsing
EXPECTED_VERSION_OUTPUT = "pip " + ensurepip._PIP_VERSION
@@ -315,7 +249,6 @@
class TestBootstrappingMainFunction(EnsurepipMixin, unittest.TestCase):
- @requires_usable_pip
def test_bootstrap_version(self):
with test.test_support.captured_stderr() as stderr:
with self.assertRaises(SystemExit):
@@ -324,7 +257,6 @@
self.assertEqual(result, EXPECTED_VERSION_OUTPUT)
self.assertFalse(self.run_pip.called)
- @requires_usable_pip
def test_basic_bootstrapping(self):
ensurepip._main([])
@@ -350,7 +282,6 @@
self.assertEqual(result, EXPECTED_VERSION_OUTPUT)
self.assertFalse(self.run_pip.called)
- @requires_usable_pip
def test_basic_uninstall(self):
with fake_pip():
ensurepip._uninstall._main([])
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list