summaryrefslogtreecommitdiff
path: root/Lib/test/test_ensurepip.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_ensurepip.py')
-rw-r--r--Lib/test/test_ensurepip.py65
1 files changed, 0 insertions, 65 deletions
diff --git a/Lib/test/test_ensurepip.py b/Lib/test/test_ensurepip.py
index a78ca14886..9b04c18b0e 100644
--- a/Lib/test/test_ensurepip.py
+++ b/Lib/test/test_ensurepip.py
@@ -9,19 +9,6 @@ import sys
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.support.import_fresh_module("ensurepip",
- blocked=["ssl"])
-try:
- import ssl
-except ImportError:
- 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):
@@ -47,7 +34,6 @@ class EnsurepipMixin:
class TestBootstrap(EnsurepipMixin, unittest.TestCase):
- @requires_usable_pip
def test_basic_bootstrapping(self):
ensurepip.bootstrap()
@@ -62,7 +48,6 @@ class TestBootstrap(EnsurepipMixin, unittest.TestCase):
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/")
@@ -75,7 +60,6 @@ class TestBootstrap(EnsurepipMixin, unittest.TestCase):
unittest.mock.ANY,
)
- @requires_usable_pip
def test_bootstrapping_with_user(self):
ensurepip.bootstrap(user=True)
@@ -87,7 +71,6 @@ class TestBootstrap(EnsurepipMixin, unittest.TestCase):
unittest.mock.ANY,
)
- @requires_usable_pip
def test_bootstrapping_with_upgrade(self):
ensurepip.bootstrap(upgrade=True)
@@ -99,7 +82,6 @@ class TestBootstrap(EnsurepipMixin, unittest.TestCase):
unittest.mock.ANY,
)
- @requires_usable_pip
def test_bootstrapping_with_verbosity_1(self):
ensurepip.bootstrap(verbosity=1)
@@ -111,7 +93,6 @@ class TestBootstrap(EnsurepipMixin, unittest.TestCase):
unittest.mock.ANY,
)
- @requires_usable_pip
def test_bootstrapping_with_verbosity_2(self):
ensurepip.bootstrap(verbosity=2)
@@ -123,7 +104,6 @@ class TestBootstrap(EnsurepipMixin, unittest.TestCase):
unittest.mock.ANY,
)
- @requires_usable_pip
def test_bootstrapping_with_verbosity_3(self):
ensurepip.bootstrap(verbosity=3)
@@ -135,17 +115,14 @@ class TestBootstrap(EnsurepipMixin, unittest.TestCase):
unittest.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)
@@ -155,7 +132,6 @@ class TestBootstrap(EnsurepipMixin, unittest.TestCase):
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
@@ -163,7 +139,6 @@ 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
@@ -205,7 +180,6 @@ class TestUninstall(EnsurepipMixin, unittest.TestCase):
self.assertFalse(self.run_pip.called)
- @requires_usable_pip
def test_uninstall(self):
with fake_pip():
ensurepip._uninstall_helper()
@@ -217,7 +191,6 @@ class TestUninstall(EnsurepipMixin, unittest.TestCase):
]
)
- @requires_usable_pip
def test_uninstall_with_verbosity_1(self):
with fake_pip():
ensurepip._uninstall_helper(verbosity=1)
@@ -229,7 +202,6 @@ class TestUninstall(EnsurepipMixin, unittest.TestCase):
]
)
- @requires_usable_pip
def test_uninstall_with_verbosity_2(self):
with fake_pip():
ensurepip._uninstall_helper(verbosity=2)
@@ -241,7 +213,6 @@ class TestUninstall(EnsurepipMixin, unittest.TestCase):
]
)
- @requires_usable_pip
def test_uninstall_with_verbosity_3(self):
with fake_pip():
ensurepip._uninstall_helper(verbosity=3)
@@ -253,7 +224,6 @@ class TestUninstall(EnsurepipMixin, unittest.TestCase):
]
)
- @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
@@ -262,7 +232,6 @@ 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
@@ -271,44 +240,12 @@ class TestUninstall(EnsurepipMixin, unittest.TestCase):
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().setUp()
-
- def test_bootstrap_requires_ssl(self):
- self.os_environ["PIP_THIS_SHOULD_STAY"] = "test fodder"
- with self.assertRaisesRegex(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.assertRaisesRegex(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.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
class TestBootstrappingMainFunction(EnsurepipMixin, unittest.TestCase):
- @requires_usable_pip
def test_bootstrap_version(self):
with test.support.captured_stdout() as stdout:
with self.assertRaises(SystemExit):
@@ -317,7 +254,6 @@ class TestBootstrappingMainFunction(EnsurepipMixin, unittest.TestCase):
self.assertEqual(result, EXPECTED_VERSION_OUTPUT)
self.assertFalse(self.run_pip.called)
- @requires_usable_pip
def test_basic_bootstrapping(self):
ensurepip._main([])
@@ -342,7 +278,6 @@ class TestUninstallationMainFunction(EnsurepipMixin, unittest.TestCase):
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([])