mirror of https://github.com/pypa/pip
Address review comments
Handle the case of invoking pip via pip3 and pip3.7
This commit is contained in:
parent
9a317d3b20
commit
a1fa84e57e
|
@ -1184,12 +1184,11 @@ def protect_pip_from_modification_on_windows(modifying_pip):
|
|||
On Windows, any operation modifying pip should be run as:
|
||||
python -m pip ...
|
||||
"""
|
||||
pip_names = [
|
||||
"pip",
|
||||
"pip.exe",
|
||||
"pip{}.exe".format(sys.version_info[0]),
|
||||
"pip{}.{}.exe".format(*sys.version_info[:2])
|
||||
]
|
||||
pip_names = set()
|
||||
for ext in ('', '.exe'):
|
||||
pip_names.add('pip{0}'.format(ext))
|
||||
pip_names.add('pip{0}{1}'.format(sys.version_info[0], ext))
|
||||
pip_names.add('pip{0}.{1}{ext}'.format(*sys.version_info[:2], ext=ext))
|
||||
|
||||
# See https://github.com/pypa/pip/issues/1299 for more discussion
|
||||
should_show_use_python_msg = (
|
||||
|
|
|
@ -1531,14 +1531,22 @@ def test_target_install_ignores_distutils_config_install_prefix(script):
|
|||
|
||||
|
||||
@pytest.mark.skipif("sys.platform != 'win32'")
|
||||
def test_protect_pip_from_modification_on_windows(script):
|
||||
@pytest.mark.parametrize('pip_name', [
|
||||
'pip',
|
||||
'pip{}'.format(sys.version_info[0]),
|
||||
'pip{}.{}'.format(*sys.version_info[:2]),
|
||||
'pip.exe',
|
||||
'pip{}.exe'.format(sys.version_info[0]),
|
||||
'pip{}.{}.exe'.format(*sys.version_info[:2])
|
||||
])
|
||||
def test_protect_pip_from_modification_on_windows(script, pip_name):
|
||||
"""
|
||||
Test ``pip install --upgrade pip`` is raised an error on Windows.
|
||||
"""
|
||||
command = ['pip', 'install', '--upgrade', 'pip']
|
||||
command = [pip_name, 'install', '--upgrade', 'pip']
|
||||
result = script.run(*command, expect_error=True)
|
||||
assert result.returncode != 0
|
||||
new_command = [sys.executable, '-m'] + command
|
||||
new_command = [sys.executable, '-m', 'pip'] + command[1:]
|
||||
assert 'To modify pip, please run the following command:\n{}'.format(
|
||||
' '.join(new_command)) in result.stderr, str(result)
|
||||
|
||||
|
|
Loading…
Reference in New Issue