pip/tests/functional/test_install_upgrade.py

475 lines
15 KiB
Python
Raw Normal View History

import itertools
2013-01-23 05:52:35 +01:00
import os
2013-07-27 09:58:56 +02:00
import sys
import textwrap
import pytest
2020-03-06 18:30:16 +01:00
from tests.lib import pyversion # noqa: F401
from tests.lib import assert_all_changes
from tests.lib.local_repos import local_checkout
from tests.lib.wheel import make_wheel
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
def test_no_upgrade_unless_requested(script):
"""
No upgrade if not specifically requested.
2010-04-22 09:43:32 +02:00
"""
2019-08-11 04:04:44 +02:00
script.pip('install', 'INITools==0.1')
result = script.pip('install', 'INITools')
assert not result.files_created, (
'pip install INITools upgraded when it should not have'
)
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,
use_new_resolver,
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 (
(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 (
(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"
if not use_new_resolver:
msg = msg + ", skipping upgrade: simple"
assert (
2020-06-18 19:05:51 +02:00
msg in result.stdout
), "did not print correct message for not-upgraded requirement"
2016-09-18 22:48:01 +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 (
(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"
expected = (
script.site_packages /
'simple-3.0.dist-info'
)
result.did_create(expected, message="should have installed simple==3.0")
expected = (
script.site_packages /
'simple-1.0.dist-info'
)
2016-09-18 22:48:01 +02:00
assert (
expected in result.files_deleted
2016-09-18 22:48:01 +02:00
), "should have uninstalled simple==1.0"
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 (
(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 (
(script.site_packages /
'simple-2.0.dist-info')
2016-09-18 22:48:01 +02:00
in result.files_deleted
), "should have uninstalled simple==2.0"
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 (
(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"
result.did_create(
script.site_packages / 'simple-3.0.dist-info',
message="should have installed simple==3.0"
)
2016-09-18 22:48:01 +02:00
assert (
script.site_packages / 'simple-1.0.dist-info'
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
def test_upgrade_to_specific_version(script, with_wheel):
"""
It does upgrade to specific version requested.
2010-04-22 09:43:32 +02:00
"""
2019-08-11 04:04:44 +02:00
script.pip('install', 'INITools==0.1')
result = script.pip('install', 'INITools==0.2')
assert result.files_created, (
'pip install with specific version did not upgrade'
)
assert (
script.site_packages / 'INITools-0.1.dist-info'
in result.files_deleted
)
result.did_create(
script.site_packages / 'INITools-0.2.dist-info'
)
2015-01-15 00:53:15 +01:00
@pytest.mark.network
def test_upgrade_if_requested(script, with_wheel):
"""
And it does upgrade if requested.
2010-04-22 09:43:32 +02:00
"""
2019-08-11 04:04:44 +02:00
script.pip('install', 'INITools==0.1')
result = script.pip('install', '--upgrade', 'INITools')
assert result.files_created, 'pip install --upgrade did not upgrade'
result.did_not_create(
script.site_packages /
'INITools-0.1.dist-info'
)
2020-06-18 19:05:51 +02:00
def test_upgrade_with_newest_already_installed(script, data, use_new_resolver):
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.
"""
script.pip('install', '-f', data.find_links, '--no-index', 'simple')
result = script.pip(
'install', '--upgrade', '-f', data.find_links, '--no-index', 'simple'
)
assert not result.files_created, 'simple upgraded when it should not have'
2020-06-18 19:05:51 +02:00
if use_new_resolver:
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
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.
"""
result = script.pip('install', 'INITools')
result.did_create(script.site_packages / 'initools')
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')
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
def test_uninstall_before_upgrade(script):
"""
Automatic uninstall-before-upgrade.
2010-04-22 09:43:32 +02:00
"""
2019-08-11 04:04:44 +02:00
result = script.pip('install', 'INITools==0.2')
result.did_create(script.site_packages / 'initools')
2019-08-11 04:04:44 +02:00
result2 = script.pip('install', 'INITools==0.3')
assert result2.files_created, 'upgrade to INITools 0.3 failed'
2019-08-11 04:04:44 +02:00
result3 = script.pip('uninstall', 'initools', '-y')
assert_all_changes(result, result3, [script.venv / 'build', 'cache'])
2015-01-15 00:53:15 +01:00
@pytest.mark.network
def test_uninstall_before_upgrade_from_url(script):
"""
Automatic uninstall-before-upgrade from URL.
"""
2019-08-11 04:04:44 +02:00
result = script.pip('install', 'INITools==0.2')
result.did_create(script.site_packages / 'initools')
result2 = script.pip(
'install',
2018-04-13 14:08:51 +02:00
'https://files.pythonhosted.org/packages/source/I/INITools/INITools-'
'0.3.tar.gz',
)
assert result2.files_created, 'upgrade to INITools 0.3 failed'
2019-08-11 04:04:44 +02:00
result3 = script.pip('uninstall', 'initools', '-y')
assert_all_changes(result, result3, [script.venv / 'build', 'cache'])
2015-01-15 00:53:15 +01:00
@pytest.mark.network
def test_upgrade_to_same_version_from_url(script):
"""
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')
result.did_create(script.site_packages / 'initools')
result2 = script.pip(
'install',
2018-04-13 14:08:51 +02:00
'https://files.pythonhosted.org/packages/source/I/INITools/INITools-'
'0.3.tar.gz',
)
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')
assert_all_changes(result, result3, [script.venv / 'build', 'cache'])
2015-01-15 00:53:15 +01:00
@pytest.mark.network
def test_upgrade_from_reqs_file(script):
"""
Upgrade from a requirements file.
2010-04-22 09:43:32 +02:00
"""
script.scratch_path.joinpath("test-req.txt").write_text(textwrap.dedent("""\
PyLogo<0.4
# and something else to test out:
INITools==0.3
"""))
install_result = script.pip(
'install', '-r', script.scratch_path / 'test-req.txt'
)
script.scratch_path.joinpath("test-req.txt").write_text(textwrap.dedent("""\
PyLogo
# and something else to test out:
INITools
"""))
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,
[script.venv / 'build', 'cache', script.scratch / 'test-req.txt'],
)
def test_uninstall_rollback(script, data):
"""
Test uninstall-rollback (using test package with a setup.py
crafted to fail on install).
2010-04-22 09:43:32 +02:00
"""
result = script.pip(
'install', '-f', data.find_links, '--no-index', 'broken==0.1'
)
result.did_create(script.site_packages / 'broken.py')
result2 = script.pip(
2014-07-04 00:56:26 +02:00
'install', '-f', data.find_links, '--no-index', 'broken===0.2broken',
expect_error=True,
)
assert result2.returncode == 1, str(result2)
assert script.run(
'python', '-c', "import broken; print(broken.VERSION)"
).stdout == '0.1\n'
assert_all_changes(
result.files_after,
result2,
[script.venv / 'build'],
)
2015-01-15 00:53:15 +01:00
@pytest.mark.network
def test_should_not_install_always_from_cache(script, with_wheel):
"""
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')
script.pip('uninstall', '-y', 'INITools')
2019-08-11 04:04:44 +02:00
result = script.pip('install', 'INITools==0.1')
result.did_not_create(
script.site_packages /
'INITools-0.2.dist-info'
)
result.did_create(
script.site_packages /
'INITools-0.1.dist-info'
)
2011-08-04 17:09:38 +02:00
2015-01-15 00:53:15 +01:00
@pytest.mark.network
def test_install_with_ignoreinstalled_requested(script, with_wheel):
"""
2013-11-29 21:49:14 +01:00
Test old conflicting package is completely ignored
"""
2019-08-11 04:04:44 +02:00
script.pip('install', 'INITools==0.1')
result = script.pip('install', '-I', 'INITools==0.3')
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.
assert os.path.exists(
script.site_packages_path /
'INITools-0.1.dist-info'
)
assert os.path.exists(
script.site_packages_path /
'INITools-0.3.dist-info'
)
2011-08-25 01:24:49 +02:00
2015-01-15 00:53:15 +01:00
@pytest.mark.network
def test_upgrade_vcs_req_with_no_dists_found(script, tmpdir):
"""It can upgrade a VCS requirement that has no distributions otherwise."""
req = "{checkout}#egg=pip-test-package".format(
checkout=local_checkout(
"git+https://github.com/pypa/pip-test-package.git", tmpdir,
)
)
script.pip("install", req)
result = script.pip("install", "-U", req)
assert not result.returncode
2015-01-15 00:53:15 +01:00
@pytest.mark.network
def test_upgrade_vcs_req_with_dist_found(script):
"""It can upgrade a VCS requirement that has distributions on the index."""
# TODO(pnasrat) Using local_checkout fails on windows - oddness with the
# test path urls/git.
req = (
"{url}#egg=pretend".format(
url=(
"git+git://github.com/alex/pretend@e7f26ad7dbcb4a02a4995aade4"
"743aad47656b27"
),
)
)
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
class TestUpgradeDistributeToSetuptools(object):
2013-07-27 09:58:56 +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
"""
def prep_ve(self, script, version, pip_src, distribute=False):
self.script = script
self.script.pip_install_local(
'virtualenv=={version}'.format(**locals()))
args = ['virtualenv', self.script.scratch_path / 'VE']
2013-07-27 09:58:56 +02:00
if distribute:
args.insert(1, '--distribute')
if version == "1.9.1" and not distribute:
# setuptools 0.6 didn't support PYTHONDONTWRITEBYTECODE
del self.script.environ["PYTHONDONTWRITEBYTECODE"]
self.script.run(*args)
if sys.platform == 'win32':
bindir = "Scripts"
else:
bindir = "bin"
self.ve_bin = self.script.scratch_path / 'VE' / bindir
self.script.run(self.ve_bin / 'pip', 'uninstall', '-y', 'pip')
self.script.run(
self.ve_bin / 'python', 'setup.py', 'install',
cwd=pip_src,
expect_stderr=True,
)
@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)