2020-07-30 15:58:05 +02:00
|
|
|
import itertools
|
2013-01-23 05:52:35 +01:00
|
|
|
import os
|
2013-07-27 09:58:56 +02:00
|
|
|
import sys
|
2010-02-24 11:24:55 +01:00
|
|
|
import textwrap
|
2013-08-18 11:59:44 +02:00
|
|
|
|
|
|
|
import pytest
|
2017-06-13 14:17:00 +02:00
|
|
|
|
2020-03-06 18:30:16 +01:00
|
|
|
from tests.lib import pyversion # noqa: F401
|
|
|
|
from tests.lib import assert_all_changes
|
2013-05-27 19:46:31 +02:00
|
|
|
from tests.lib.local_repos import local_checkout
|
2020-07-30 15:58:05 +02:00
|
|
|
from tests.lib.wheel import make_wheel
|
2010-02-24 11:24:55 +01:00
|
|
|
|
2010-06-03 04:25:26 +02:00
|
|
|
|
Mark 6 tests as network tests
=================================== FAILURES ===================================
_______________________________ test_freeze_path _______________________________
tmpdir = Path('/tmp/pytest-of-mockbuild/pytest-0/test_freeze_path0')
script = <tests.lib.PipTestEnvironment object at 0x7fe950a4caf0>
data = <tests.lib.TestData object at 0x7fe950a4cc10>
def test_freeze_path(tmpdir, script, data):
"""
Test freeze with --path.
"""
> script.pip('install', '--find-links', data.find_links,
'--target', tmpdir, 'simple==2.0')
tests/functional/test_freeze.py:712:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/lib/__init__.py:593: in run
_check_stderr(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
stderr = "WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'N...t at 0x7fe6435ef280>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/simple/\n"
allow_stderr_warning = False, allow_stderr_error = False
def _check_stderr(
stderr, allow_stderr_warning, allow_stderr_error,
):
"""
Check the given stderr for logged warnings and errors.
:param stderr: stderr output as a string.
:param allow_stderr_warning: whether a logged warning (or deprecation
message) is allowed. Must be True if allow_stderr_error is True.
:param allow_stderr_error: whether a logged error is allowed.
"""
assert not (allow_stderr_error and not allow_stderr_warning)
lines = stderr.splitlines()
for line in lines:
# First check for logging errors, which we don't allow during
# tests even if allow_stderr_error=True (since a logging error
# would signal a bug in pip's code).
# Unlike errors logged with logger.error(), these errors are
# sent directly to stderr and so bypass any configured log formatter.
# The "--- Logging error ---" string is used in Python 3.4+, and
# "Logged from file " is used in Python 2.
if (line.startswith('--- Logging error ---') or
line.startswith('Logged from file ')):
reason = 'stderr has a logging error, which is never allowed'
msg = make_check_stderr_message(stderr, line=line, reason=reason)
raise RuntimeError(msg)
if allow_stderr_error:
continue
if line.startswith('ERROR: '):
reason = (
'stderr has an unexpected error '
'(pass allow_stderr_error=True to permit this)'
)
msg = make_check_stderr_message(stderr, line=line, reason=reason)
raise RuntimeError(msg)
if allow_stderr_warning:
continue
if (line.startswith('WARNING: ') or
line.startswith(DEPRECATION_MSG_PREFIX)):
reason = (
'stderr has an unexpected warning '
'(pass allow_stderr_warning=True to permit this)'
)
msg = make_check_stderr_message(stderr, line=line, reason=reason)
> raise RuntimeError(msg)
E RuntimeError: stderr has an unexpected warning (pass allow_stderr_warning=True to permit this):
E Caused by line: "WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fe64364c850>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/simple/"
E Complete stderr: WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fe64364c850>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/simple/
E WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fe64364cdc0>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/simple/
E WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fe64364cf70>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/simple/
E WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fe6435ef130>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/simple/
E WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fe6435ef280>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/simple/
tests/lib/__init__.py:404: RuntimeError
________________________ test_freeze_path_exclude_user _________________________
tmpdir = Path('/tmp/pytest-of-mockbuild/pytest-0/test_freeze_path_exclude_user0')
script = <tests.lib.PipTestEnvironment object at 0x7fe950ec8fa0>
data = <tests.lib.TestData object at 0x7fe950ec8a30>
def test_freeze_path_exclude_user(tmpdir, script, data):
"""
Test freeze with --path and make sure packages from --user are not picked
up.
"""
script.pip_install_local('--find-links', data.find_links,
'--user', 'simple2')
> script.pip('install', '--find-links', data.find_links,
'--target', tmpdir, 'simple==1.0')
tests/functional/test_freeze.py:728:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/lib/__init__.py:593: in run
_check_stderr(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
stderr = "WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'N...t at 0x7f87ae751310>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/simple/\n"
allow_stderr_warning = False, allow_stderr_error = False
def _check_stderr(
stderr, allow_stderr_warning, allow_stderr_error,
):
"""
Check the given stderr for logged warnings and errors.
:param stderr: stderr output as a string.
:param allow_stderr_warning: whether a logged warning (or deprecation
message) is allowed. Must be True if allow_stderr_error is True.
:param allow_stderr_error: whether a logged error is allowed.
"""
assert not (allow_stderr_error and not allow_stderr_warning)
lines = stderr.splitlines()
for line in lines:
# First check for logging errors, which we don't allow during
# tests even if allow_stderr_error=True (since a logging error
# would signal a bug in pip's code).
# Unlike errors logged with logger.error(), these errors are
# sent directly to stderr and so bypass any configured log formatter.
# The "--- Logging error ---" string is used in Python 3.4+, and
# "Logged from file " is used in Python 2.
if (line.startswith('--- Logging error ---') or
line.startswith('Logged from file ')):
reason = 'stderr has a logging error, which is never allowed'
msg = make_check_stderr_message(stderr, line=line, reason=reason)
raise RuntimeError(msg)
if allow_stderr_error:
continue
if line.startswith('ERROR: '):
reason = (
'stderr has an unexpected error '
'(pass allow_stderr_error=True to permit this)'
)
msg = make_check_stderr_message(stderr, line=line, reason=reason)
raise RuntimeError(msg)
if allow_stderr_warning:
continue
if (line.startswith('WARNING: ') or
line.startswith(DEPRECATION_MSG_PREFIX)):
reason = (
'stderr has an unexpected warning '
'(pass allow_stderr_warning=True to permit this)'
)
msg = make_check_stderr_message(stderr, line=line, reason=reason)
> raise RuntimeError(msg)
E RuntimeError: stderr has an unexpected warning (pass allow_stderr_warning=True to permit this):
E Caused by line: "WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f87ae7aa8e0>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/simple/"
E Complete stderr: WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f87ae7aa8e0>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/simple/
E WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f87ae7aae50>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/simple/
E WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f87ae751040>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/simple/
E WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f87ae7511c0>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/simple/
E WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f87ae751310>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/simple/
tests/lib/__init__.py:404: RuntimeError
__________________________ test_freeze_path_multiple ___________________________
tmpdir = Path('/tmp/pytest-of-mockbuild/pytest-0/test_freeze_path_multiple0')
script = <tests.lib.PipTestEnvironment object at 0x7fe950b43fd0>
data = <tests.lib.TestData object at 0x7fe950b43df0>
def test_freeze_path_multiple(tmpdir, script, data):
"""
Test freeze with multiple --path arguments.
"""
path1 = tmpdir / "path1"
os.mkdir(path1)
path2 = tmpdir / "path2"
os.mkdir(path2)
> script.pip('install', '--find-links', data.find_links,
'--target', path1, 'simple==2.0')
tests/functional/test_freeze.py:750:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/lib/__init__.py:593: in run
_check_stderr(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
stderr = "WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'N...t at 0x7f07e6253280>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/simple/\n"
allow_stderr_warning = False, allow_stderr_error = False
def _check_stderr(
stderr, allow_stderr_warning, allow_stderr_error,
):
"""
Check the given stderr for logged warnings and errors.
:param stderr: stderr output as a string.
:param allow_stderr_warning: whether a logged warning (or deprecation
message) is allowed. Must be True if allow_stderr_error is True.
:param allow_stderr_error: whether a logged error is allowed.
"""
assert not (allow_stderr_error and not allow_stderr_warning)
lines = stderr.splitlines()
for line in lines:
# First check for logging errors, which we don't allow during
# tests even if allow_stderr_error=True (since a logging error
# would signal a bug in pip's code).
# Unlike errors logged with logger.error(), these errors are
# sent directly to stderr and so bypass any configured log formatter.
# The "--- Logging error ---" string is used in Python 3.4+, and
# "Logged from file " is used in Python 2.
if (line.startswith('--- Logging error ---') or
line.startswith('Logged from file ')):
reason = 'stderr has a logging error, which is never allowed'
msg = make_check_stderr_message(stderr, line=line, reason=reason)
raise RuntimeError(msg)
if allow_stderr_error:
continue
if line.startswith('ERROR: '):
reason = (
'stderr has an unexpected error '
'(pass allow_stderr_error=True to permit this)'
)
msg = make_check_stderr_message(stderr, line=line, reason=reason)
raise RuntimeError(msg)
if allow_stderr_warning:
continue
if (line.startswith('WARNING: ') or
line.startswith(DEPRECATION_MSG_PREFIX)):
reason = (
'stderr has an unexpected warning '
'(pass allow_stderr_warning=True to permit this)'
)
msg = make_check_stderr_message(stderr, line=line, reason=reason)
> raise RuntimeError(msg)
E RuntimeError: stderr has an unexpected warning (pass allow_stderr_warning=True to permit this):
E Caused by line: "WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f07e62ae850>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/simple/"
E Complete stderr: WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f07e62ae850>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/simple/
E WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f07e62aedc0>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/simple/
E WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f07e62aef70>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/simple/
E WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f07e6253130>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/simple/
E WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f07e6253280>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/simple/
tests/lib/__init__.py:404: RuntimeError
_________________ test_install_no_binary_builds_pep_517_wheel __________________
script = <tests.lib.PipTestEnvironment object at 0x7fe9509f4e20>
data = <tests.lib.TestData object at 0x7fe9509f4640>, with_wheel = None
def test_install_no_binary_builds_pep_517_wheel(script, data, with_wheel):
to_install = data.packages.joinpath('pep517_setup_and_pyproject')
> res = script.pip(
'install', '--no-binary=:all:', '-f', data.find_links, to_install
)
tests/functional/test_install.py:1279:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <tests.lib.PipTestEnvironment object at 0x7fe9509f4e20>
args = ('python', '-m', 'pip', 'install', '--no-binary=:all:', '-f', ...)
kw = {'expect_stderr': True}
cwd = Path('/tmp/pytest-of-mockbuild/pytest-0/test_install_no_binary_builds_0/workspace/scratch')
run_from = None, allow_stderr_error = False, allow_stderr_warning = False
expect_error = None
def run(self, *args, **kw):
"""
:param allow_stderr_error: whether a logged error is allowed in
stderr. Passing True for this argument implies
`allow_stderr_warning` since warnings are weaker than errors.
:param allow_stderr_warning: whether a logged warning (or
deprecation message) is allowed in stderr.
:param expect_error: if False (the default), asserts that the command
exits with 0. Otherwise, asserts that the command exits with a
non-zero exit code. Passing True also implies allow_stderr_error
and allow_stderr_warning.
:param expect_stderr: whether to allow warnings in stderr (equivalent
to `allow_stderr_warning`). This argument is an abbreviated
version of `allow_stderr_warning` and is also kept for backwards
compatibility.
"""
if self.verbose:
print('>> running %s %s' % (args, kw))
cwd = kw.pop('cwd', None)
run_from = kw.pop('run_from', None)
assert not cwd or not run_from, "Don't use run_from; it's going away"
cwd = cwd or run_from or self.cwd
if sys.platform == 'win32':
# Partial fix for ScriptTest.run using `shell=True` on Windows.
args = [str(a).replace('^', '^^').replace('&', '^&') for a in args]
# Remove `allow_stderr_error` and `allow_stderr_warning` before
# calling run() because PipTestEnvironment doesn't support them.
allow_stderr_error = kw.pop('allow_stderr_error', None)
allow_stderr_warning = kw.pop('allow_stderr_warning', None)
# Propagate default values.
expect_error = kw.get('expect_error')
if expect_error:
# Then default to allowing logged errors.
if allow_stderr_error is not None and not allow_stderr_error:
raise RuntimeError(
'cannot pass allow_stderr_error=False with '
'expect_error=True'
)
allow_stderr_error = True
elif kw.get('expect_stderr'):
# Then default to allowing logged warnings.
if allow_stderr_warning is not None and not allow_stderr_warning:
raise RuntimeError(
'cannot pass allow_stderr_warning=False with '
'expect_stderr=True'
)
allow_stderr_warning = True
if allow_stderr_error:
if allow_stderr_warning is not None and not allow_stderr_warning:
raise RuntimeError(
'cannot pass allow_stderr_warning=False with '
'allow_stderr_error=True'
)
# Default values if not set.
if allow_stderr_error is None:
allow_stderr_error = False
if allow_stderr_warning is None:
allow_stderr_warning = allow_stderr_error
# Pass expect_stderr=True to allow any stderr. We do this because
# we do our checking of stderr further on in check_stderr().
kw['expect_stderr'] = True
> result = super(PipTestEnvironment, self).run(cwd=cwd, *args, **kw)
E AssertionError: Script returned code: 1
tests/lib/__init__.py:586: AssertionError
----------------------------- Captured stdout call -----------------------------
Script result: python -m pip install --no-binary=:all: -f file:///tmp/pytest-of-mockbuild/pytest-0/test_install_no_binary_builds_0/data/packages /tmp/pytest-of-mockbuild/pytest-0/test_install_no_binary_builds_0/data/packages/pep517_setup_and_pyproject
return code: 1
-- stderr: --------------------
ERROR: Command errored out with exit status 1:
command: /tmp/pytest-of-mockbuild/pytest-0/test_install_no_binary_builds_0/workspace/venv/bin/python /builddir/build/BUILDROOT/python-pip-19.3.1-1.fc32.noarch/usr/lib/python3.8/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pytest-of-mockbuild/pytest-0/test_install_no_binary_builds_0/workspace/tmp/pip-build-env-ntp1m4dh/overlay --no-warn-script-location --no-binary :all: --only-binary :none: -i https://pypi.org/simple --find-links file:///tmp/pytest-of-mockbuild/pytest-0/test_install_no_binary_builds_0/data/packages -- setuptools
cwd: None
Complete output (28 lines):
Looking in links: file:///tmp/pytest-of-mockbuild/pytest-0/test_install_no_binary_builds_0/data/packages
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f7234ef1e50>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/setuptools/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f7234e92040>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/setuptools/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f7234e921c0>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/setuptools/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f7234e92340>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/setuptools/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f7234e924c0>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/setuptools/
Processing /tmp/pytest-of-mockbuild/pytest-0/test_install_no_binary_builds_0/data/packages/setuptools-0.9.6.tar.gz
ERROR: Command errored out with exit status 1:
command: /tmp/pytest-of-mockbuild/pytest-0/test_install_no_binary_builds_0/workspace/venv/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pytest-of-mockbuild/pytest-0/test_install_no_binary_builds_0/workspace/tmp/pip-install-b_6lf4z6/setuptools/setup.py'"'"'; __file__='"'"'/tmp/pytest-of-mockbuild/pytest-0/test_install_no_binary_builds_0/workspace/tmp/pip-install-b_6lf4z6/setuptools/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pytest-of-mockbuild/pytest-0/test_install_no_binary_builds_0/workspace/tmp/pip-install-b_6lf4z6/setuptools/pip-egg-info
cwd: /tmp/pytest-of-mockbuild/pytest-0/test_install_no_binary_builds_0/workspace/tmp/pip-install-b_6lf4z6/setuptools/
Complete output (15 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pytest-of-mockbuild/pytest-0/test_install_no_binary_builds_0/workspace/tmp/pip-install-b_6lf4z6/setuptools/setuptools/__init__.py", line 2, in <module>
from setuptools.extension import Extension, Library
File "/tmp/pytest-of-mockbuild/pytest-0/test_install_no_binary_builds_0/workspace/tmp/pip-install-b_6lf4z6/setuptools/setuptools/extension.py", line 5, in <module>
from setuptools.dist import _get_unpatched
File "/tmp/pytest-of-mockbuild/pytest-0/test_install_no_binary_builds_0/workspace/tmp/pip-install-b_6lf4z6/setuptools/setuptools/dist.py", line 7, in <module>
from setuptools.command.install import install
File "/tmp/pytest-of-mockbuild/pytest-0/test_install_no_binary_builds_0/workspace/tmp/pip-install-b_6lf4z6/setuptools/setuptools/command/__init__.py", line 8, in <module>
from setuptools.command import install_scripts
File "/tmp/pytest-of-mockbuild/pytest-0/test_install_no_binary_builds_0/workspace/tmp/pip-install-b_6lf4z6/setuptools/setuptools/command/install_scripts.py", line 3, in <module>
from pkg_resources import Distribution, PathMetadata, ensure_directory
File "/tmp/pytest-of-mockbuild/pytest-0/test_install_no_binary_builds_0/workspace/tmp/pip-install-b_6lf4z6/setuptools/pkg_resources.py", line 1545, in <module>
register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
----------------------------------------
ERROR: Command errored out with exit status 1: /tmp/pytest-of-mockbuild/pytest-0/test_install_no_binary_builds_0/workspace/venv/bin/python /builddir/build/BUILDROOT/python-pip-19.3.1-1.fc32.noarch/usr/lib/python3.8/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pytest-of-mockbuild/pytest-0/test_install_no_binary_builds_0/workspace/tmp/pip-build-env-ntp1m4dh/overlay --no-warn-script-location --no-binary :all: --only-binary :none: -i https://pypi.org/simple --find-links file:///tmp/pytest-of-mockbuild/pytest-0/test_install_no_binary_builds_0/data/packages -- setuptools Check the logs for full command output.
-- stdout: --------------------
Looking in links: file:///tmp/pytest-of-mockbuild/pytest-0/test_install_no_binary_builds_0/data/packages
Processing /tmp/pytest-of-mockbuild/pytest-0/test_install_no_binary_builds_0/data/packages/pep517_setup_and_pyproject
Installing build dependencies: started
Installing build dependencies: finished with status 'error'
_______________________ test_config_file_override_stack ________________________
script = <tests.lib.PipTestEnvironment object at 0x7fe950d9b7f0>
virtualenv = <VirtualEnvironment /tmp/pytest-of-mockbuild/pytest-0/test_config_file_override_stac0/workspace/venv>
def test_config_file_override_stack(script, virtualenv):
"""
Test config files (global, overriding a global config with a
local, overriding all with a command line flag).
"""
fd, config_file = tempfile.mkstemp('-pip.cfg', 'test-')
try:
> _test_config_file_override_stack(script, virtualenv, config_file)
tests/functional/test_install_config.py:144:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/functional/test_install_config.py:172: in _test_config_file_override_stack
result = script.pip(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <tests.lib.PipTestEnvironment object at 0x7fe950d9b7f0>
args = ('python', '-m', 'pip', 'install', '-vvv', '--index-url', ...)
kw = {'expect_stderr': True}
cwd = Path('/tmp/pytest-of-mockbuild/pytest-0/test_config_file_override_stac0/workspace/scratch')
run_from = None, allow_stderr_error = False, allow_stderr_warning = False
expect_error = None
def run(self, *args, **kw):
"""
:param allow_stderr_error: whether a logged error is allowed in
stderr. Passing True for this argument implies
`allow_stderr_warning` since warnings are weaker than errors.
:param allow_stderr_warning: whether a logged warning (or
deprecation message) is allowed in stderr.
:param expect_error: if False (the default), asserts that the command
exits with 0. Otherwise, asserts that the command exits with a
non-zero exit code. Passing True also implies allow_stderr_error
and allow_stderr_warning.
:param expect_stderr: whether to allow warnings in stderr (equivalent
to `allow_stderr_warning`). This argument is an abbreviated
version of `allow_stderr_warning` and is also kept for backwards
compatibility.
"""
if self.verbose:
print('>> running %s %s' % (args, kw))
cwd = kw.pop('cwd', None)
run_from = kw.pop('run_from', None)
assert not cwd or not run_from, "Don't use run_from; it's going away"
cwd = cwd or run_from or self.cwd
if sys.platform == 'win32':
# Partial fix for ScriptTest.run using `shell=True` on Windows.
args = [str(a).replace('^', '^^').replace('&', '^&') for a in args]
# Remove `allow_stderr_error` and `allow_stderr_warning` before
# calling run() because PipTestEnvironment doesn't support them.
allow_stderr_error = kw.pop('allow_stderr_error', None)
allow_stderr_warning = kw.pop('allow_stderr_warning', None)
# Propagate default values.
expect_error = kw.get('expect_error')
if expect_error:
# Then default to allowing logged errors.
if allow_stderr_error is not None and not allow_stderr_error:
raise RuntimeError(
'cannot pass allow_stderr_error=False with '
'expect_error=True'
)
allow_stderr_error = True
elif kw.get('expect_stderr'):
# Then default to allowing logged warnings.
if allow_stderr_warning is not None and not allow_stderr_warning:
raise RuntimeError(
'cannot pass allow_stderr_warning=False with '
'expect_stderr=True'
)
allow_stderr_warning = True
if allow_stderr_error:
if allow_stderr_warning is not None and not allow_stderr_warning:
raise RuntimeError(
'cannot pass allow_stderr_warning=False with '
'allow_stderr_error=True'
)
# Default values if not set.
if allow_stderr_error is None:
allow_stderr_error = False
if allow_stderr_warning is None:
allow_stderr_warning = allow_stderr_error
# Pass expect_stderr=True to allow any stderr. We do this because
# we do our checking of stderr further on in check_stderr().
kw['expect_stderr'] = True
> result = super(PipTestEnvironment, self).run(cwd=cwd, *args, **kw)
E AssertionError: Script returned code: 1
tests/lib/__init__.py:586: AssertionError
----------------------------- Captured stdout call -----------------------------
Script result: python -m pip install -vvv --index-url https://pypi.org/simple/ INITools
return code: 1
-- stderr: --------------------
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f9669c3d8b0>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/initools/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f9669c3da60>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/initools/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f9669c3dbe0>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/initools/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f9669c3dd60>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/initools/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f966900f490>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/initools/
ERROR: Could not find a version that satisfies the requirement INITools (from versions: none)
ERROR: No matching distribution found for INITools
-- stdout: --------------------
Created temporary directory: /tmp/pytest-of-mockbuild/pytest-0/test_config_file_override_stac0/workspace/tmp/pip-ephem-wheel-cache-6gj33ens
Created temporary directory: /tmp/pytest-of-mockbuild/pytest-0/test_config_file_override_stac0/workspace/tmp/pip-req-tracker-s7_2cwgc
Created requirements tracker '/tmp/pytest-of-mockbuild/pytest-0/test_config_file_override_stac0/workspace/tmp/pip-req-tracker-s7_2cwgc'
Created temporary directory: /tmp/pytest-of-mockbuild/pytest-0/test_config_file_override_stac0/workspace/tmp/pip-install-_91mh3df
Looking in indexes: https://pypi.org/simple/
1 location(s) to search for versions of INITools:
* https://pypi.org/simple/initools/
Getting page https://pypi.org/simple/initools/
Found index url https://pypi.org/simple/
Looking up "https://pypi.org/simple/initools/" in the cache
Request header has "max_age" as 0, cache bypassed
Starting new HTTPS connection (1): pypi.org:443
Incremented Retry for (url='/simple/initools/'): Retry(total=4, connect=None, read=None, redirect=None, status=None)
Starting new HTTPS connection (2): pypi.org:443
Incremented Retry for (url='/simple/initools/'): Retry(total=3, connect=None, read=None, redirect=None, status=None)
Starting new HTTPS connection (3): pypi.org:443
Incremented Retry for (url='/simple/initools/'): Retry(total=2, connect=None, read=None, redirect=None, status=None)
Starting new HTTPS connection (4): pypi.org:443
Incremented Retry for (url='/simple/initools/'): Retry(total=1, connect=None, read=None, redirect=None, status=None)
Starting new HTTPS connection (5): pypi.org:443
Incremented Retry for (url='/simple/initools/'): Retry(total=0, connect=None, read=None, redirect=None, status=None)
Starting new HTTPS connection (6): pypi.org:443
Could not fetch URL https://pypi.org/simple/initools/: connection error: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/initools/ (Caused by NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f9669c15b50>: Failed to establish a new connection: [Errno -2] Name or service not known')) - skipping
Given no hashes to check 0 links for project 'INITools': discarding no candidates
Cleaning up...
Removed build tracker '/tmp/pytest-of-mockbuild/pytest-0/test_config_file_override_stac0/workspace/tmp/pip-req-tracker-s7_2cwgc'
Exception information:
Traceback (most recent call last):
File "/builddir/build/BUILDROOT/python-pip-19.3.1-1.fc32.noarch/usr/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 153, in _main
status = self.run(options, args)
File "/builddir/build/BUILDROOT/python-pip-19.3.1-1.fc32.noarch/usr/lib/python3.8/site-packages/pip/_internal/commands/install.py", line 401, in run
resolver.resolve(requirement_set)
File "/builddir/build/BUILDROOT/python-pip-19.3.1-1.fc32.noarch/usr/lib/python3.8/site-packages/pip/_internal/legacy_resolve.py", line 202, in resolve
self._resolve_one(requirement_set, req)
File "/builddir/build/BUILDROOT/python-pip-19.3.1-1.fc32.noarch/usr/lib/python3.8/site-packages/pip/_internal/legacy_resolve.py", line 368, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "/builddir/build/BUILDROOT/python-pip-19.3.1-1.fc32.noarch/usr/lib/python3.8/site-packages/pip/_internal/legacy_resolve.py", line 314, in _get_abstract_dist_for
req.populate_link(self.finder, upgrade_allowed, self.require_hashes)
File "/builddir/build/BUILDROOT/python-pip-19.3.1-1.fc32.noarch/usr/lib/python3.8/site-packages/pip/_internal/req/req_install.py", line 226, in populate_link
self.link = finder.find_requirement(self, upgrade)
File "/builddir/build/BUILDROOT/python-pip-19.3.1-1.fc32.noarch/usr/lib/python3.8/site-packages/pip/_internal/index.py", line 905, in find_requirement
raise DistributionNotFound(
pip._internal.exceptions.DistributionNotFound: No matching distribution found for INITools
_______________________ test_no_upgrade_unless_requested _______________________
script = <tests.lib.PipTestEnvironment object at 0x7fe950d86070>
def test_no_upgrade_unless_requested(script):
"""
No upgrade if not specifically requested.
"""
> script.pip('install', 'INITools==0.1')
tests/functional/test_install_upgrade.py:16:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <tests.lib.PipTestEnvironment object at 0x7fe950d86070>
args = ('python', '-m', 'pip', 'install', 'INITools==0.1')
kw = {'expect_stderr': True}
cwd = Path('/tmp/pytest-of-mockbuild/pytest-0/test_no_upgrade_unless_request0/workspace/scratch')
run_from = None, allow_stderr_error = False, allow_stderr_warning = False
expect_error = None
def run(self, *args, **kw):
"""
:param allow_stderr_error: whether a logged error is allowed in
stderr. Passing True for this argument implies
`allow_stderr_warning` since warnings are weaker than errors.
:param allow_stderr_warning: whether a logged warning (or
deprecation message) is allowed in stderr.
:param expect_error: if False (the default), asserts that the command
exits with 0. Otherwise, asserts that the command exits with a
non-zero exit code. Passing True also implies allow_stderr_error
and allow_stderr_warning.
:param expect_stderr: whether to allow warnings in stderr (equivalent
to `allow_stderr_warning`). This argument is an abbreviated
version of `allow_stderr_warning` and is also kept for backwards
compatibility.
"""
if self.verbose:
print('>> running %s %s' % (args, kw))
cwd = kw.pop('cwd', None)
run_from = kw.pop('run_from', None)
assert not cwd or not run_from, "Don't use run_from; it's going away"
cwd = cwd or run_from or self.cwd
if sys.platform == 'win32':
# Partial fix for ScriptTest.run using `shell=True` on Windows.
args = [str(a).replace('^', '^^').replace('&', '^&') for a in args]
# Remove `allow_stderr_error` and `allow_stderr_warning` before
# calling run() because PipTestEnvironment doesn't support them.
allow_stderr_error = kw.pop('allow_stderr_error', None)
allow_stderr_warning = kw.pop('allow_stderr_warning', None)
# Propagate default values.
expect_error = kw.get('expect_error')
if expect_error:
# Then default to allowing logged errors.
if allow_stderr_error is not None and not allow_stderr_error:
raise RuntimeError(
'cannot pass allow_stderr_error=False with '
'expect_error=True'
)
allow_stderr_error = True
elif kw.get('expect_stderr'):
# Then default to allowing logged warnings.
if allow_stderr_warning is not None and not allow_stderr_warning:
raise RuntimeError(
'cannot pass allow_stderr_warning=False with '
'expect_stderr=True'
)
allow_stderr_warning = True
if allow_stderr_error:
if allow_stderr_warning is not None and not allow_stderr_warning:
raise RuntimeError(
'cannot pass allow_stderr_warning=False with '
'allow_stderr_error=True'
)
# Default values if not set.
if allow_stderr_error is None:
allow_stderr_error = False
if allow_stderr_warning is None:
allow_stderr_warning = allow_stderr_error
# Pass expect_stderr=True to allow any stderr. We do this because
# we do our checking of stderr further on in check_stderr().
kw['expect_stderr'] = True
> result = super(PipTestEnvironment, self).run(cwd=cwd, *args, **kw)
E AssertionError: Script returned code: 1
tests/lib/__init__.py:586: AssertionError
----------------------------- Captured stdout call -----------------------------
Script result: python -m pip install INITools==0.1
return code: 1
-- stderr: --------------------
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fd66cc36700>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/initools/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fd66cc36c40>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/initools/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fd66cc36dc0>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/initools/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fd66cc36f40>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/initools/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fd66be48100>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/initools/
ERROR: Could not find a version that satisfies the requirement INITools==0.1 (from versions: none)
ERROR: No matching distribution found for INITools==0.1
2019-11-15 19:44:54 +01:00
|
|
|
@pytest.mark.network
|
2013-08-22 06:40:46 +02:00
|
|
|
def test_no_upgrade_unless_requested(script):
|
2010-02-25 00:16:43 +01:00
|
|
|
"""
|
|
|
|
No upgrade if not specifically requested.
|
2010-04-22 09:43:32 +02:00
|
|
|
|
2010-02-25 00:16:43 +01:00
|
|
|
"""
|
2019-08-11 04:04:44 +02:00
|
|
|
script.pip('install', 'INITools==0.1')
|
|
|
|
result = script.pip('install', 'INITools')
|
2014-01-28 15:17:51 +01:00
|
|
|
assert not result.files_created, (
|
|
|
|
'pip install INITools upgraded when it should not have'
|
|
|
|
)
|
2010-02-24 11:24:55 +01:00
|
|
|
|
2010-06-03 04:25:26 +02:00
|
|
|
|
2016-09-18 22:48:01 +02:00
|
|
|
def test_invalid_upgrade_strategy_causes_error(script):
|
|
|
|
"""
|
|
|
|
It errors out when the upgrade-strategy is an invalid/unrecognised one
|
|
|
|
|
|
|
|
"""
|
|
|
|
result = script.pip_install_local(
|
|
|
|
'--upgrade', '--upgrade-strategy=bazinga', 'simple',
|
|
|
|
expect_error=True
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result.returncode
|
|
|
|
assert "invalid choice" in result.stderr
|
|
|
|
|
|
|
|
|
2020-06-18 19:05:51 +02:00
|
|
|
def test_only_if_needed_does_not_upgrade_deps_when_satisfied(
|
|
|
|
script,
|
2020-10-30 01:28:02 +01:00
|
|
|
resolver_variant,
|
2020-07-25 13:02:20 +02:00
|
|
|
with_wheel
|
2020-06-18 19:05:51 +02:00
|
|
|
):
|
2016-09-18 22:48:01 +02:00
|
|
|
"""
|
|
|
|
It doesn't upgrade a dependency if it already satisfies the requirements.
|
|
|
|
|
|
|
|
"""
|
2019-08-11 04:04:44 +02:00
|
|
|
script.pip_install_local('simple==2.0')
|
2016-09-18 22:48:01 +02:00
|
|
|
result = script.pip_install_local(
|
2019-08-11 04:04:44 +02:00
|
|
|
'--upgrade', '--upgrade-strategy=only-if-needed', 'require_simple'
|
2016-09-18 22:48:01 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
assert (
|
2020-07-25 13:02:20 +02:00
|
|
|
(script.site_packages / 'require_simple-1.0.dist-info')
|
2016-09-18 22:48:01 +02:00
|
|
|
not in result.files_deleted
|
|
|
|
), "should have installed require_simple==1.0"
|
|
|
|
assert (
|
2020-07-25 13:02:20 +02:00
|
|
|
(script.site_packages / 'simple-2.0.dist-info')
|
2016-09-18 22:48:01 +02:00
|
|
|
not in result.files_deleted
|
|
|
|
), "should not have uninstalled simple==2.0"
|
2020-06-18 19:05:51 +02:00
|
|
|
|
|
|
|
msg = "Requirement already satisfied"
|
2020-10-30 01:28:02 +01:00
|
|
|
if resolver_variant == "legacy":
|
2020-06-18 19:05:51 +02:00
|
|
|
msg = msg + ", skipping upgrade: simple"
|
2018-06-19 08:46:43 +02:00
|
|
|
assert (
|
2020-06-18 19:05:51 +02:00
|
|
|
msg in result.stdout
|
2018-06-19 08:46:43 +02:00
|
|
|
), "did not print correct message for not-upgraded requirement"
|
2016-09-18 22:48:01 +02:00
|
|
|
|
|
|
|
|
2020-07-25 13:02:20 +02:00
|
|
|
def test_only_if_needed_does_upgrade_deps_when_no_longer_satisfied(
|
|
|
|
script, with_wheel
|
|
|
|
):
|
2016-09-18 22:48:01 +02:00
|
|
|
"""
|
|
|
|
It does upgrade a dependency if it no longer satisfies the requirements.
|
|
|
|
|
|
|
|
"""
|
2019-08-11 04:04:44 +02:00
|
|
|
script.pip_install_local('simple==1.0')
|
2016-09-18 22:48:01 +02:00
|
|
|
result = script.pip_install_local(
|
2019-08-11 04:04:44 +02:00
|
|
|
'--upgrade', '--upgrade-strategy=only-if-needed', 'require_simple'
|
2016-09-18 22:48:01 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
assert (
|
2020-07-25 13:02:20 +02:00
|
|
|
(script.site_packages / 'require_simple-1.0.dist-info')
|
2016-09-18 22:48:01 +02:00
|
|
|
not in result.files_deleted
|
|
|
|
), "should have installed require_simple==1.0"
|
2020-02-29 20:53:59 +01:00
|
|
|
expected = (
|
|
|
|
script.site_packages /
|
2020-07-25 13:02:20 +02:00
|
|
|
'simple-3.0.dist-info'
|
2020-02-29 20:53:59 +01:00
|
|
|
)
|
2020-05-28 11:38:38 +02:00
|
|
|
result.did_create(expected, message="should have installed simple==3.0")
|
2020-02-29 20:53:59 +01:00
|
|
|
expected = (
|
|
|
|
script.site_packages /
|
2020-07-25 13:02:20 +02:00
|
|
|
'simple-1.0.dist-info'
|
2020-02-29 20:53:59 +01:00
|
|
|
)
|
2016-09-18 22:48:01 +02:00
|
|
|
assert (
|
2020-02-29 20:53:59 +01:00
|
|
|
expected in result.files_deleted
|
2016-09-18 22:48:01 +02:00
|
|
|
), "should have uninstalled simple==1.0"
|
|
|
|
|
|
|
|
|
2020-07-25 13:02:20 +02:00
|
|
|
def test_eager_does_upgrade_dependecies_when_currently_satisfied(
|
|
|
|
script, with_wheel
|
|
|
|
):
|
2016-09-18 22:48:01 +02:00
|
|
|
"""
|
|
|
|
It does upgrade a dependency even if it already satisfies the requirements.
|
|
|
|
|
|
|
|
"""
|
2019-08-11 04:04:44 +02:00
|
|
|
script.pip_install_local('simple==2.0')
|
2016-09-18 22:48:01 +02:00
|
|
|
result = script.pip_install_local(
|
2019-08-11 04:04:44 +02:00
|
|
|
'--upgrade', '--upgrade-strategy=eager', 'require_simple'
|
2016-09-18 22:48:01 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
assert (
|
2020-02-29 20:53:59 +01:00
|
|
|
(script.site_packages /
|
2020-07-25 13:02:20 +02:00
|
|
|
'require_simple-1.0.dist-info')
|
2016-09-18 22:48:01 +02:00
|
|
|
not in result.files_deleted
|
|
|
|
), "should have installed require_simple==1.0"
|
|
|
|
assert (
|
2020-02-29 20:53:59 +01:00
|
|
|
(script.site_packages /
|
2020-07-25 13:02:20 +02:00
|
|
|
'simple-2.0.dist-info')
|
2016-09-18 22:48:01 +02:00
|
|
|
in result.files_deleted
|
|
|
|
), "should have uninstalled simple==2.0"
|
|
|
|
|
|
|
|
|
2020-07-25 13:02:20 +02:00
|
|
|
def test_eager_does_upgrade_dependecies_when_no_longer_satisfied(
|
|
|
|
script, with_wheel
|
|
|
|
):
|
2016-09-18 22:48:01 +02:00
|
|
|
"""
|
|
|
|
It does upgrade a dependency if it no longer satisfies the requirements.
|
|
|
|
|
|
|
|
"""
|
2019-08-11 04:04:44 +02:00
|
|
|
script.pip_install_local('simple==1.0')
|
2016-09-18 22:48:01 +02:00
|
|
|
result = script.pip_install_local(
|
2019-08-11 04:04:44 +02:00
|
|
|
'--upgrade', '--upgrade-strategy=eager', 'require_simple'
|
2016-09-18 22:48:01 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
assert (
|
2020-07-25 13:02:20 +02:00
|
|
|
(script.site_packages / 'require_simple-1.0.dist-info')
|
2016-09-18 22:48:01 +02:00
|
|
|
not in result.files_deleted
|
|
|
|
), "should have installed require_simple==1.0"
|
2020-05-26 16:43:28 +02:00
|
|
|
result.did_create(
|
2020-07-25 13:02:20 +02:00
|
|
|
script.site_packages / 'simple-3.0.dist-info',
|
2020-05-28 11:38:38 +02:00
|
|
|
message="should have installed simple==3.0"
|
2020-05-26 16:43:28 +02:00
|
|
|
)
|
2016-09-18 22:48:01 +02:00
|
|
|
assert (
|
2020-07-25 13:02:20 +02:00
|
|
|
script.site_packages / 'simple-1.0.dist-info'
|
2020-02-29 20:53:59 +01:00
|
|
|
in result.files_deleted
|
2016-09-18 22:48:01 +02:00
|
|
|
), "should have uninstalled simple==1.0"
|
|
|
|
|
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2020-07-25 13:02:20 +02:00
|
|
|
def test_upgrade_to_specific_version(script, with_wheel):
|
2010-02-25 00:16:43 +01:00
|
|
|
"""
|
|
|
|
It does upgrade to specific version requested.
|
2010-04-22 09:43:32 +02:00
|
|
|
|
2010-02-25 00:16:43 +01:00
|
|
|
"""
|
2019-08-11 04:04:44 +02:00
|
|
|
script.pip('install', 'INITools==0.1')
|
|
|
|
result = script.pip('install', 'INITools==0.2')
|
2014-01-28 15:17:51 +01:00
|
|
|
assert result.files_created, (
|
|
|
|
'pip install with specific version did not upgrade'
|
|
|
|
)
|
|
|
|
assert (
|
2020-07-25 13:02:20 +02:00
|
|
|
script.site_packages / 'INITools-0.1.dist-info'
|
2020-02-29 20:53:59 +01:00
|
|
|
in result.files_deleted
|
2014-01-28 15:17:51 +01:00
|
|
|
)
|
2020-05-26 16:43:28 +02:00
|
|
|
result.did_create(
|
2020-07-25 13:02:20 +02:00
|
|
|
script.site_packages / 'INITools-0.2.dist-info'
|
2014-01-28 15:17:51 +01:00
|
|
|
)
|
2010-02-24 11:24:55 +01:00
|
|
|
|
2010-06-03 04:25:26 +02:00
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2020-07-25 13:02:20 +02:00
|
|
|
def test_upgrade_if_requested(script, with_wheel):
|
2010-02-25 00:16:43 +01:00
|
|
|
"""
|
|
|
|
And it does upgrade if requested.
|
2010-04-22 09:43:32 +02:00
|
|
|
|
2010-02-25 00:16:43 +01:00
|
|
|
"""
|
2019-08-11 04:04:44 +02:00
|
|
|
script.pip('install', 'INITools==0.1')
|
|
|
|
result = script.pip('install', '--upgrade', 'INITools')
|
2010-06-04 03:47:19 +02:00
|
|
|
assert result.files_created, 'pip install --upgrade did not upgrade'
|
2020-05-26 16:43:28 +02:00
|
|
|
result.did_not_create(
|
2020-02-29 20:53:59 +01:00
|
|
|
script.site_packages /
|
2020-07-25 13:02:20 +02:00
|
|
|
'INITools-0.1.dist-info'
|
2014-01-28 15:17:51 +01:00
|
|
|
)
|
2010-02-24 11:24:55 +01:00
|
|
|
|
2010-06-03 04:25:26 +02:00
|
|
|
|
2020-10-30 01:28:02 +01:00
|
|
|
def test_upgrade_with_newest_already_installed(script, data, resolver_variant):
|
2011-08-25 01:24:49 +02:00
|
|
|
"""
|
|
|
|
If the newest version of a package is already installed, the package should
|
|
|
|
not be reinstalled and the user should be informed.
|
|
|
|
"""
|
2013-08-23 13:12:37 +02:00
|
|
|
script.pip('install', '-f', data.find_links, '--no-index', 'simple')
|
2014-01-28 15:17:51 +01:00
|
|
|
result = script.pip(
|
|
|
|
'install', '--upgrade', '-f', data.find_links, '--no-index', 'simple'
|
|
|
|
)
|
2012-09-23 23:58:14 +02:00
|
|
|
assert not result.files_created, 'simple upgraded when it should not have'
|
2020-10-30 01:28:02 +01:00
|
|
|
if resolver_variant == "2020-resolver":
|
2020-06-18 19:05:51 +02:00
|
|
|
msg = "Requirement already satisfied"
|
|
|
|
else:
|
|
|
|
msg = "already up-to-date"
|
|
|
|
assert msg in result.stdout, result.stdout
|
2011-08-25 01:24:49 +02:00
|
|
|
|
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2013-08-22 06:40:46 +02:00
|
|
|
def test_upgrade_force_reinstall_newest(script):
|
2011-08-25 01:24:49 +02:00
|
|
|
"""
|
|
|
|
Force reinstallation of a package even if it is already at its newest
|
|
|
|
version if --force-reinstall is supplied.
|
|
|
|
"""
|
2013-08-21 11:16:07 +02:00
|
|
|
result = script.pip('install', 'INITools')
|
2020-05-28 11:38:38 +02:00
|
|
|
result.did_create(script.site_packages / 'initools')
|
2014-01-28 15:17:51 +01:00
|
|
|
result2 = script.pip(
|
|
|
|
'install', '--upgrade', '--force-reinstall', 'INITools'
|
|
|
|
)
|
2011-08-25 01:24:49 +02:00
|
|
|
assert result2.files_updated, 'upgrade to INITools 0.3 failed'
|
2019-08-11 04:04:44 +02:00
|
|
|
result3 = script.pip('uninstall', 'initools', '-y')
|
2014-02-24 22:52:23 +01:00
|
|
|
assert_all_changes(result, result3, [script.venv / 'build', 'cache'])
|
2011-08-25 01:24:49 +02:00
|
|
|
|
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2013-08-22 06:40:46 +02:00
|
|
|
def test_uninstall_before_upgrade(script):
|
2010-02-25 00:16:43 +01:00
|
|
|
"""
|
|
|
|
Automatic uninstall-before-upgrade.
|
2010-04-22 09:43:32 +02:00
|
|
|
|
2010-02-25 00:16:43 +01:00
|
|
|
"""
|
2019-08-11 04:04:44 +02:00
|
|
|
result = script.pip('install', 'INITools==0.2')
|
2020-05-28 11:38:38 +02:00
|
|
|
result.did_create(script.site_packages / 'initools')
|
2019-08-11 04:04:44 +02:00
|
|
|
result2 = script.pip('install', 'INITools==0.3')
|
2010-02-24 11:24:55 +01:00
|
|
|
assert result2.files_created, 'upgrade to INITools 0.3 failed'
|
2019-08-11 04:04:44 +02:00
|
|
|
result3 = script.pip('uninstall', 'initools', '-y')
|
2014-02-24 22:52:23 +01:00
|
|
|
assert_all_changes(result, result3, [script.venv / 'build', 'cache'])
|
2010-02-24 11:24:55 +01:00
|
|
|
|
2011-05-04 09:44:02 +02:00
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2013-08-22 06:40:46 +02:00
|
|
|
def test_uninstall_before_upgrade_from_url(script):
|
2011-02-12 11:48:03 +01:00
|
|
|
"""
|
|
|
|
Automatic uninstall-before-upgrade from URL.
|
|
|
|
|
|
|
|
"""
|
2019-08-11 04:04:44 +02:00
|
|
|
result = script.pip('install', 'INITools==0.2')
|
2020-05-28 11:38:38 +02:00
|
|
|
result.did_create(script.site_packages / 'initools')
|
2014-01-28 15:17:51 +01:00
|
|
|
result2 = script.pip(
|
|
|
|
'install',
|
2018-04-13 14:08:51 +02:00
|
|
|
'https://files.pythonhosted.org/packages/source/I/INITools/INITools-'
|
2014-01-28 15:17:51 +01:00
|
|
|
'0.3.tar.gz',
|
|
|
|
)
|
2011-02-12 11:48:03 +01:00
|
|
|
assert result2.files_created, 'upgrade to INITools 0.3 failed'
|
2019-08-11 04:04:44 +02:00
|
|
|
result3 = script.pip('uninstall', 'initools', '-y')
|
2014-02-24 22:52:23 +01:00
|
|
|
assert_all_changes(result, result3, [script.venv / 'build', 'cache'])
|
2010-06-03 04:25:26 +02:00
|
|
|
|
2011-05-04 09:44:02 +02:00
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2013-08-22 06:40:46 +02:00
|
|
|
def test_upgrade_to_same_version_from_url(script):
|
2011-02-13 10:05:26 +01:00
|
|
|
"""
|
|
|
|
When installing from a URL the same version that is already installed, no
|
|
|
|
need to uninstall and reinstall if --upgrade is not specified.
|
|
|
|
|
|
|
|
"""
|
2019-08-11 04:04:44 +02:00
|
|
|
result = script.pip('install', 'INITools==0.3')
|
2020-05-28 11:38:38 +02:00
|
|
|
result.did_create(script.site_packages / 'initools')
|
2014-01-28 15:17:51 +01:00
|
|
|
result2 = script.pip(
|
|
|
|
'install',
|
2018-04-13 14:08:51 +02:00
|
|
|
'https://files.pythonhosted.org/packages/source/I/INITools/INITools-'
|
2014-01-28 15:17:51 +01:00
|
|
|
'0.3.tar.gz',
|
|
|
|
)
|
2019-10-09 14:54:46 +02:00
|
|
|
assert script.site_packages / 'initools' not in result2.files_updated, (
|
|
|
|
'INITools 0.3 reinstalled same version'
|
|
|
|
)
|
2019-08-11 04:04:44 +02:00
|
|
|
result3 = script.pip('uninstall', 'initools', '-y')
|
2014-02-24 22:52:23 +01:00
|
|
|
assert_all_changes(result, result3, [script.venv / 'build', 'cache'])
|
2011-02-13 10:05:26 +01:00
|
|
|
|
2011-05-04 09:44:02 +02:00
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2013-08-22 06:40:46 +02:00
|
|
|
def test_upgrade_from_reqs_file(script):
|
2010-02-25 00:16:43 +01:00
|
|
|
"""
|
|
|
|
Upgrade from a requirements file.
|
2010-04-22 09:43:32 +02:00
|
|
|
|
2010-02-25 00:16:43 +01:00
|
|
|
"""
|
2019-07-02 07:00:32 +02:00
|
|
|
script.scratch_path.joinpath("test-req.txt").write_text(textwrap.dedent("""\
|
2010-02-24 11:24:55 +01:00
|
|
|
PyLogo<0.4
|
|
|
|
# and something else to test out:
|
|
|
|
INITools==0.3
|
2010-02-25 00:16:43 +01:00
|
|
|
"""))
|
2014-01-28 15:17:51 +01:00
|
|
|
install_result = script.pip(
|
|
|
|
'install', '-r', script.scratch_path / 'test-req.txt'
|
|
|
|
)
|
2019-07-02 07:00:32 +02:00
|
|
|
script.scratch_path.joinpath("test-req.txt").write_text(textwrap.dedent("""\
|
2010-02-24 11:24:55 +01:00
|
|
|
PyLogo
|
|
|
|
# and something else to test out:
|
|
|
|
INITools
|
2010-02-25 00:16:43 +01:00
|
|
|
"""))
|
2014-01-28 15:17:51 +01:00
|
|
|
script.pip(
|
|
|
|
'install', '--upgrade', '-r', script.scratch_path / 'test-req.txt'
|
|
|
|
)
|
|
|
|
uninstall_result = script.pip(
|
|
|
|
'uninstall', '-r', script.scratch_path / 'test-req.txt', '-y'
|
|
|
|
)
|
|
|
|
assert_all_changes(
|
|
|
|
install_result,
|
|
|
|
uninstall_result,
|
2014-02-24 22:52:23 +01:00
|
|
|
[script.venv / 'build', 'cache', script.scratch / 'test-req.txt'],
|
2014-01-28 15:17:51 +01:00
|
|
|
)
|
2010-02-24 11:24:55 +01:00
|
|
|
|
2010-06-03 04:25:26 +02:00
|
|
|
|
2013-08-23 13:12:37 +02:00
|
|
|
def test_uninstall_rollback(script, data):
|
2010-02-25 00:16:43 +01:00
|
|
|
"""
|
|
|
|
Test uninstall-rollback (using test package with a setup.py
|
|
|
|
crafted to fail on install).
|
2010-04-22 09:43:32 +02:00
|
|
|
|
2010-02-25 00:16:43 +01:00
|
|
|
"""
|
2014-01-28 15:17:51 +01:00
|
|
|
result = script.pip(
|
|
|
|
'install', '-f', data.find_links, '--no-index', 'broken==0.1'
|
|
|
|
)
|
2020-05-28 11:38:38 +02:00
|
|
|
result.did_create(script.site_packages / 'broken.py')
|
2014-01-28 15:17:51 +01:00
|
|
|
result2 = script.pip(
|
2014-07-04 00:56:26 +02:00
|
|
|
'install', '-f', data.find_links, '--no-index', 'broken===0.2broken',
|
2014-01-28 15:17:51 +01:00
|
|
|
expect_error=True,
|
|
|
|
)
|
2010-02-24 11:24:55 +01:00
|
|
|
assert result2.returncode == 1, str(result2)
|
2014-01-28 15:17:51 +01:00
|
|
|
assert script.run(
|
|
|
|
'python', '-c', "import broken; print(broken.VERSION)"
|
|
|
|
).stdout == '0.1\n'
|
|
|
|
assert_all_changes(
|
|
|
|
result.files_after,
|
|
|
|
result2,
|
2014-08-31 01:52:28 +02:00
|
|
|
[script.venv / 'build'],
|
2014-01-28 15:17:51 +01:00
|
|
|
)
|
2010-07-30 18:06:36 +02:00
|
|
|
|
2013-08-22 06:40:46 +02:00
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2020-07-25 13:02:20 +02:00
|
|
|
def test_should_not_install_always_from_cache(script, with_wheel):
|
2010-11-23 02:55:15 +01:00
|
|
|
"""
|
|
|
|
If there is an old cached package, pip should download the newer version
|
|
|
|
Related to issue #175
|
|
|
|
"""
|
2019-08-11 04:04:44 +02:00
|
|
|
script.pip('install', 'INITools==0.2')
|
2013-08-21 11:16:07 +02:00
|
|
|
script.pip('uninstall', '-y', 'INITools')
|
2019-08-11 04:04:44 +02:00
|
|
|
result = script.pip('install', 'INITools==0.1')
|
2020-05-26 16:43:28 +02:00
|
|
|
result.did_not_create(
|
2020-02-29 20:53:59 +01:00
|
|
|
script.site_packages /
|
2020-07-25 13:02:20 +02:00
|
|
|
'INITools-0.2.dist-info'
|
2014-01-28 15:17:51 +01:00
|
|
|
)
|
2020-05-26 16:43:28 +02:00
|
|
|
result.did_create(
|
2020-02-29 20:53:59 +01:00
|
|
|
script.site_packages /
|
2020-07-25 13:02:20 +02:00
|
|
|
'INITools-0.1.dist-info'
|
2014-01-28 15:17:51 +01:00
|
|
|
)
|
2011-06-02 14:57:36 +02:00
|
|
|
|
2011-08-04 17:09:38 +02:00
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2020-07-25 13:02:20 +02:00
|
|
|
def test_install_with_ignoreinstalled_requested(script, with_wheel):
|
2011-06-02 14:57:36 +02:00
|
|
|
"""
|
2013-11-29 21:49:14 +01:00
|
|
|
Test old conflicting package is completely ignored
|
2011-06-02 14:57:36 +02:00
|
|
|
"""
|
2019-08-11 04:04:44 +02:00
|
|
|
script.pip('install', 'INITools==0.1')
|
|
|
|
result = script.pip('install', '-I', 'INITools==0.3')
|
2011-06-02 14:57:36 +02:00
|
|
|
assert result.files_created, 'pip install -I did not install'
|
2013-11-29 21:49:14 +01:00
|
|
|
# both the old and new metadata should be present.
|
2014-01-28 15:17:51 +01:00
|
|
|
assert os.path.exists(
|
2020-02-29 20:53:59 +01:00
|
|
|
script.site_packages_path /
|
2020-07-25 13:02:20 +02:00
|
|
|
'INITools-0.1.dist-info'
|
2014-01-28 15:17:51 +01:00
|
|
|
)
|
|
|
|
assert os.path.exists(
|
2020-02-29 20:53:59 +01:00
|
|
|
script.site_packages_path /
|
2020-07-25 13:02:20 +02:00
|
|
|
'INITools-0.3.dist-info'
|
2014-01-28 15:17:51 +01:00
|
|
|
)
|
2011-08-25 01:24:49 +02:00
|
|
|
|
2012-03-16 08:40:58 +01:00
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2013-08-22 12:14:09 +02:00
|
|
|
def test_upgrade_vcs_req_with_no_dists_found(script, tmpdir):
|
2012-03-16 08:40:58 +01:00
|
|
|
"""It can upgrade a VCS requirement that has no distributions otherwise."""
|
2020-02-29 20:53:59 +01:00
|
|
|
req = "{checkout}#egg=pip-test-package".format(
|
|
|
|
checkout=local_checkout(
|
|
|
|
"git+https://github.com/pypa/pip-test-package.git", tmpdir,
|
|
|
|
)
|
2014-01-28 15:17:51 +01:00
|
|
|
)
|
2013-08-21 11:16:07 +02:00
|
|
|
script.pip("install", req)
|
|
|
|
result = script.pip("install", "-U", req)
|
2012-03-16 08:40:58 +01:00
|
|
|
assert not result.returncode
|
2012-03-20 03:46:47 +01:00
|
|
|
|
|
|
|
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2013-08-22 06:40:46 +02:00
|
|
|
def test_upgrade_vcs_req_with_dist_found(script):
|
2012-03-20 03:46:47 +01:00
|
|
|
"""It can upgrade a VCS requirement that has distributions on the index."""
|
2014-01-28 15:17:51 +01:00
|
|
|
# TODO(pnasrat) Using local_checkout fails on windows - oddness with the
|
|
|
|
# test path urls/git.
|
|
|
|
req = (
|
2020-02-29 20:53:59 +01:00
|
|
|
"{url}#egg=pretend".format(
|
|
|
|
url=(
|
|
|
|
"git+git://github.com/alex/pretend@e7f26ad7dbcb4a02a4995aade4"
|
|
|
|
"743aad47656b27"
|
|
|
|
),
|
2014-01-28 15:17:51 +01:00
|
|
|
)
|
|
|
|
)
|
2015-03-16 13:34:52 +01:00
|
|
|
script.pip("install", req, expect_stderr=True)
|
|
|
|
result = script.pip("install", "-U", req, expect_stderr=True)
|
2018-04-13 14:08:51 +02:00
|
|
|
assert "pypi.org" not in result.stdout, result.stdout
|
2013-07-27 09:58:56 +02:00
|
|
|
|
|
|
|
|
2015-05-09 20:58:55 +02:00
|
|
|
class TestUpgradeDistributeToSetuptools(object):
|
2013-07-27 09:58:56 +02:00
|
|
|
"""
|
2015-05-09 20:58:55 +02:00
|
|
|
From pip1.4 to pip6, pip supported a set of "hacks" (see Issue #1122) to
|
|
|
|
allow distribute to conflict with setuptools, so that the following would
|
|
|
|
work to upgrade distribute:
|
|
|
|
|
|
|
|
``pip install -U setuptools``
|
|
|
|
|
|
|
|
In pip7, the hacks were removed. This test remains to at least confirm pip
|
|
|
|
can upgrade distribute to setuptools using:
|
|
|
|
|
|
|
|
``pip install -U distribute``
|
|
|
|
|
|
|
|
The reason this works is that a final version of distribute (v0.7.3) was
|
|
|
|
released that is simple wrapper with:
|
|
|
|
|
|
|
|
install_requires=['setuptools>=0.7']
|
|
|
|
|
|
|
|
The test use a fixed set of packages from our test packages dir. Note that
|
|
|
|
virtualenv-1.9.1 contains distribute-0.6.34 and virtualenv-1.10 contains
|
|
|
|
setuptools-0.9.7
|
2013-07-27 09:58:56 +02:00
|
|
|
"""
|
|
|
|
|
2013-08-24 12:43:01 +02:00
|
|
|
def prep_ve(self, script, version, pip_src, distribute=False):
|
2013-08-22 06:40:46 +02:00
|
|
|
self.script = script
|
2020-02-29 20:53:59 +01:00
|
|
|
self.script.pip_install_local(
|
|
|
|
'virtualenv=={version}'.format(**locals()))
|
2014-02-24 22:52:23 +01:00
|
|
|
args = ['virtualenv', self.script.scratch_path / 'VE']
|
2013-07-27 09:58:56 +02:00
|
|
|
if distribute:
|
|
|
|
args.insert(1, '--distribute')
|
2013-08-22 09:52:23 +02:00
|
|
|
if version == "1.9.1" and not distribute:
|
|
|
|
# setuptools 0.6 didn't support PYTHONDONTWRITEBYTECODE
|
|
|
|
del self.script.environ["PYTHONDONTWRITEBYTECODE"]
|
2013-08-21 11:16:07 +02:00
|
|
|
self.script.run(*args)
|
2013-10-23 21:21:48 +02:00
|
|
|
if sys.platform == 'win32':
|
|
|
|
bindir = "Scripts"
|
|
|
|
else:
|
|
|
|
bindir = "bin"
|
2014-02-24 22:52:23 +01:00
|
|
|
self.ve_bin = self.script.scratch_path / 'VE' / bindir
|
|
|
|
self.script.run(self.ve_bin / 'pip', 'uninstall', '-y', 'pip')
|
2014-01-28 15:17:51 +01:00
|
|
|
self.script.run(
|
2014-02-24 22:52:23 +01:00
|
|
|
self.ve_bin / 'python', 'setup.py', 'install',
|
2013-08-24 12:43:01 +02:00
|
|
|
cwd=pip_src,
|
|
|
|
expect_stderr=True,
|
|
|
|
)
|
2020-07-30 15:58:05 +02:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize("req1, req2", list(itertools.product(
|
|
|
|
["foo.bar", "foo_bar", "foo-bar"], ["foo.bar", "foo_bar", "foo-bar"],
|
|
|
|
)))
|
|
|
|
def test_install_find_existing_package_canonicalize(script, req1, req2):
|
|
|
|
"""Ensure an already-installed dist is found no matter how the dist name
|
|
|
|
was normalized on installation. (pypa/pip#8645)
|
|
|
|
"""
|
|
|
|
# Create and install a package that's not available in the later stage.
|
|
|
|
req_container = script.scratch_path.joinpath("foo-bar")
|
|
|
|
req_container.mkdir()
|
|
|
|
req_path = make_wheel("foo_bar", "1.0").save_to_dir(req_container)
|
|
|
|
script.pip("install", "--no-index", req_path)
|
|
|
|
|
|
|
|
# Depend on the previously installed, but now unavailable package.
|
|
|
|
pkg_container = script.scratch_path.joinpath("pkg")
|
|
|
|
pkg_container.mkdir()
|
|
|
|
make_wheel(
|
|
|
|
"pkg",
|
|
|
|
"1.0",
|
|
|
|
metadata_updates={"Requires-Dist": req2},
|
|
|
|
).save_to_dir(pkg_container)
|
|
|
|
|
|
|
|
# Ensure the previously installed package can be correctly used to match
|
|
|
|
# the dependency.
|
|
|
|
result = script.pip(
|
|
|
|
"install", "--no-index", "--find-links", pkg_container, "pkg",
|
|
|
|
)
|
|
|
|
satisfied_message = "Requirement already satisfied: {}".format(req2)
|
|
|
|
assert satisfied_message in result.stdout, str(result)
|