Merge pull request #8623 from sbidoul/remove-egg-info-tests-1-sbi

Reduce reliance on .egg-info directories in test suite
This commit is contained in:
Stéphane Bidoul 2020-07-25 16:11:18 +02:00 committed by GitHub
commit aff33ffc4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 165 additions and 153 deletions

View File

@ -188,7 +188,8 @@ def test_pep518_forkbombs(script, data, common_wheels, command, package):
@pytest.mark.network @pytest.mark.network
def test_pip_second_command_line_interface_works( def test_pip_second_command_line_interface_works(
script, pip_src, data, common_wheels, deprecated_python): script, pip_src, data, common_wheels, deprecated_python, with_wheel
):
""" """
Check if ``pip<PYVERSION>`` commands behaves equally Check if ``pip<PYVERSION>`` commands behaves equally
""" """
@ -204,12 +205,12 @@ def test_pip_second_command_line_interface_works(
args.extend(['install', 'INITools==0.2']) args.extend(['install', 'INITools==0.2'])
args.extend(['-f', data.packages]) args.extend(['-f', data.packages])
result = script.run(*args, **kwargs) result = script.run(*args, **kwargs)
egg_info_folder = ( dist_info_folder = (
script.site_packages / script.site_packages /
'INITools-0.2-py{pyversion}.egg-info'.format(**globals()) 'INITools-0.2.dist-info'
) )
initools_folder = script.site_packages / 'initools' initools_folder = script.site_packages / 'initools'
result.did_create(egg_info_folder) result.did_create(dist_info_folder)
result.did_create(initools_folder) result.did_create(initools_folder)
@ -231,17 +232,17 @@ def test_install_exit_status_code_when_blank_requirements_file(script):
@pytest.mark.network @pytest.mark.network
def test_basic_install_from_pypi(script): def test_basic_install_from_pypi(script, with_wheel):
""" """
Test installing a package from PyPI. Test installing a package from PyPI.
""" """
result = script.pip('install', 'INITools==0.2') result = script.pip('install', 'INITools==0.2')
egg_info_folder = ( dist_info_folder = (
script.site_packages / script.site_packages /
'INITools-0.2-py{pyversion}.egg-info'.format(**globals()) 'INITools-0.2.dist-info'
) )
initools_folder = script.site_packages / 'initools' initools_folder = script.site_packages / 'initools'
result.did_create(egg_info_folder) result.did_create(dist_info_folder)
result.did_create(initools_folder) result.did_create(initools_folder)
# Should not display where it's looking for files # Should not display where it's looking for files
@ -406,7 +407,9 @@ def test_vcs_url_urlquote_normalization(script, tmpdir):
@pytest.mark.parametrize("resolver", ["", "--use-feature=2020-resolver"]) @pytest.mark.parametrize("resolver", ["", "--use-feature=2020-resolver"])
def test_basic_install_from_local_directory(script, data, resolver): def test_basic_install_from_local_directory(
script, data, resolver, with_wheel
):
""" """
Test installing from a local directory. Test installing from a local directory.
""" """
@ -417,12 +420,12 @@ def test_basic_install_from_local_directory(script, data, resolver):
args.append(to_install) args.append(to_install)
result = script.pip(*args) result = script.pip(*args)
fspkg_folder = script.site_packages / 'fspkg' fspkg_folder = script.site_packages / 'fspkg'
egg_info_folder = ( dist_info_folder = (
script.site_packages / script.site_packages /
'FSPkg-0.1.dev0-py{pyversion}.egg-info'.format(**globals()) 'FSPkg-0.1.dev0.dist-info'
) )
result.did_create(fspkg_folder) result.did_create(fspkg_folder)
result.did_create(egg_info_folder) result.did_create(dist_info_folder)
@pytest.mark.parametrize("test_type,editable", [ @pytest.mark.parametrize("test_type,editable", [
@ -433,13 +436,15 @@ def test_basic_install_from_local_directory(script, data, resolver):
("embedded_rel_path", False), ("embedded_rel_path", False),
("embedded_rel_path", True), ("embedded_rel_path", True),
]) ])
def test_basic_install_relative_directory(script, data, test_type, editable): def test_basic_install_relative_directory(
script, data, test_type, editable, with_wheel
):
""" """
Test installing a requirement using a relative path. Test installing a requirement using a relative path.
""" """
egg_info_file = ( dist_info_folder = (
script.site_packages / script.site_packages /
'FSPkg-0.1.dev0-py{pyversion}.egg-info'.format(**globals()) 'FSPkg-0.1.dev0.dist-info'
) )
egg_link_file = ( egg_link_file = (
script.site_packages / 'FSPkg.egg-link' script.site_packages / 'FSPkg.egg-link'
@ -465,7 +470,7 @@ def test_basic_install_relative_directory(script, data, test_type, editable):
if not editable: if not editable:
result = script.pip('install', req_path, result = script.pip('install', req_path,
cwd=script.scratch_path) cwd=script.scratch_path)
result.did_create(egg_info_file) result.did_create(dist_info_folder)
result.did_create(package_folder) result.did_create(package_folder)
else: else:
# Editable install. # Editable install.
@ -562,29 +567,32 @@ def test_hashed_install_failure_later_flag(script, tmpdir):
def test_install_from_local_directory_with_symlinks_to_directories( def test_install_from_local_directory_with_symlinks_to_directories(
script, data): script, data, with_wheel
):
""" """
Test installing from a local directory containing symlinks to directories. Test installing from a local directory containing symlinks to directories.
""" """
to_install = data.packages.joinpath("symlinks") to_install = data.packages.joinpath("symlinks")
result = script.pip('install', to_install) result = script.pip('install', to_install)
pkg_folder = script.site_packages / 'symlinks' pkg_folder = script.site_packages / 'symlinks'
egg_info_folder = ( dist_info_folder = (
script.site_packages / script.site_packages /
'symlinks-0.1.dev0-py{pyversion}.egg-info'.format(**globals()) 'symlinks-0.1.dev0.dist-info'
) )
result.did_create(pkg_folder) result.did_create(pkg_folder)
result.did_create(egg_info_folder) result.did_create(dist_info_folder)
@pytest.mark.skipif("sys.platform == 'win32' or sys.version_info < (3,)") @pytest.mark.skipif("sys.platform == 'win32' or sys.version_info < (3,)")
def test_install_from_local_directory_with_socket_file(script, data, tmpdir): def test_install_from_local_directory_with_socket_file(
script, data, tmpdir, with_wheel
):
""" """
Test installing from a local directory containing a socket file. Test installing from a local directory containing a socket file.
""" """
egg_info_file = ( dist_info_folder = (
script.site_packages / script.site_packages /
"FSPkg-0.1.dev0-py{pyversion}.egg-info".format(**globals()) "FSPkg-0.1.dev0.dist-info"
) )
package_folder = script.site_packages / "fspkg" package_folder = script.site_packages / "fspkg"
to_copy = data.packages.joinpath("FSPkg") to_copy = data.packages.joinpath("FSPkg")
@ -597,7 +605,7 @@ def test_install_from_local_directory_with_socket_file(script, data, tmpdir):
result = script.pip("install", "--verbose", to_install) result = script.pip("install", "--verbose", to_install)
result.did_create(package_folder) result.did_create(package_folder)
result.did_create(egg_info_file) result.did_create(dist_info_folder)
assert str(socket_file_path) in result.stderr assert str(socket_file_path) in result.stderr
@ -673,7 +681,7 @@ def test_upgrade_argparse_shadowed(script):
assert "Not uninstalling argparse" not in result.stdout assert "Not uninstalling argparse" not in result.stdout
def test_install_curdir(script, data): def test_install_curdir(script, data, with_wheel):
""" """
Test installing current directory ('.'). Test installing current directory ('.').
""" """
@ -684,27 +692,27 @@ def test_install_curdir(script, data):
rmtree(egg_info) rmtree(egg_info)
result = script.pip('install', curdir, cwd=run_from) result = script.pip('install', curdir, cwd=run_from)
fspkg_folder = script.site_packages / 'fspkg' fspkg_folder = script.site_packages / 'fspkg'
egg_info_folder = ( dist_info_folder = (
script.site_packages / script.site_packages /
'FSPkg-0.1.dev0-py{pyversion}.egg-info'.format(**globals()) 'FSPkg-0.1.dev0.dist-info'
) )
result.did_create(fspkg_folder) result.did_create(fspkg_folder)
result.did_create(egg_info_folder) result.did_create(dist_info_folder)
def test_install_pardir(script, data): def test_install_pardir(script, data, with_wheel):
""" """
Test installing parent directory ('..'). Test installing parent directory ('..').
""" """
run_from = data.packages.joinpath("FSPkg", "fspkg") run_from = data.packages.joinpath("FSPkg", "fspkg")
result = script.pip('install', pardir, cwd=run_from) result = script.pip('install', pardir, cwd=run_from)
fspkg_folder = script.site_packages / 'fspkg' fspkg_folder = script.site_packages / 'fspkg'
egg_info_folder = ( dist_info_folder = (
script.site_packages / script.site_packages /
'FSPkg-0.1.dev0-py{pyversion}.egg-info'.format(**globals()) 'FSPkg-0.1.dev0.dist-info'
) )
result.did_create(fspkg_folder) result.did_create(fspkg_folder)
result.did_create(egg_info_folder) result.did_create(dist_info_folder)
@pytest.mark.network @pytest.mark.network
@ -765,17 +773,17 @@ def test_install_global_option_using_editable(script, tmpdir):
@pytest.mark.network @pytest.mark.network
def test_install_package_with_same_name_in_curdir(script): def test_install_package_with_same_name_in_curdir(script, with_wheel):
""" """
Test installing a package with the same name of a local folder Test installing a package with the same name of a local folder
""" """
script.scratch_path.joinpath("mock==0.6").mkdir() script.scratch_path.joinpath("mock==0.6").mkdir()
result = script.pip('install', 'mock==0.6') result = script.pip('install', 'mock==0.6')
egg_folder = ( dist_info_folder = (
script.site_packages / script.site_packages /
'mock-0.6.0-py{pyversion}.egg-info'.format(**globals()) 'mock-0.6.0.dist-info'
) )
result.did_create(egg_folder) result.did_create(dist_info_folder)
mock100_setup_py = textwrap.dedent('''\ mock100_setup_py = textwrap.dedent('''\
@ -784,7 +792,7 @@ mock100_setup_py = textwrap.dedent('''\
version='100.1')''') version='100.1')''')
def test_install_folder_using_dot_slash(script): def test_install_folder_using_dot_slash(script, with_wheel):
""" """
Test installing a folder using pip install ./foldername Test installing a folder using pip install ./foldername
""" """
@ -792,14 +800,14 @@ def test_install_folder_using_dot_slash(script):
pkg_path = script.scratch_path / 'mock' pkg_path = script.scratch_path / 'mock'
pkg_path.joinpath("setup.py").write_text(mock100_setup_py) pkg_path.joinpath("setup.py").write_text(mock100_setup_py)
result = script.pip('install', './mock') result = script.pip('install', './mock')
egg_folder = ( dist_info_folder = (
script.site_packages / script.site_packages /
'mock-100.1-py{pyversion}.egg-info'.format(**globals()) 'mock-100.1.dist-info'
) )
result.did_create(egg_folder) result.did_create(dist_info_folder)
def test_install_folder_using_slash_in_the_end(script): def test_install_folder_using_slash_in_the_end(script, with_wheel):
r""" r"""
Test installing a folder using pip install foldername/ or foldername\ Test installing a folder using pip install foldername/ or foldername\
""" """
@ -807,14 +815,14 @@ def test_install_folder_using_slash_in_the_end(script):
pkg_path = script.scratch_path / 'mock' pkg_path = script.scratch_path / 'mock'
pkg_path.joinpath("setup.py").write_text(mock100_setup_py) pkg_path.joinpath("setup.py").write_text(mock100_setup_py)
result = script.pip('install', 'mock' + os.path.sep) result = script.pip('install', 'mock' + os.path.sep)
egg_folder = ( dist_info_folder = (
script.site_packages / script.site_packages /
'mock-100.1-py{pyversion}.egg-info'.format(**globals()) 'mock-100.1.dist-info'
) )
result.did_create(egg_folder) result.did_create(dist_info_folder)
def test_install_folder_using_relative_path(script): def test_install_folder_using_relative_path(script, with_wheel):
""" """
Test installing a folder using pip install folder1/folder2 Test installing a folder using pip install folder1/folder2
""" """
@ -823,29 +831,29 @@ def test_install_folder_using_relative_path(script):
pkg_path = script.scratch_path / 'initools' / 'mock' pkg_path = script.scratch_path / 'initools' / 'mock'
pkg_path.joinpath("setup.py").write_text(mock100_setup_py) pkg_path.joinpath("setup.py").write_text(mock100_setup_py)
result = script.pip('install', Path('initools') / 'mock') result = script.pip('install', Path('initools') / 'mock')
egg_folder = ( dist_info_folder = (
script.site_packages / script.site_packages /
'mock-100.1-py{pyversion}.egg-info'.format(**globals()) 'mock-100.1.dist-info'.format(**globals())
) )
result.did_create(egg_folder) result.did_create(dist_info_folder)
@pytest.mark.network @pytest.mark.network
def test_install_package_which_contains_dev_in_name(script): def test_install_package_which_contains_dev_in_name(script, with_wheel):
""" """
Test installing package from PyPI which contains 'dev' in name Test installing package from PyPI which contains 'dev' in name
""" """
result = script.pip('install', 'django-devserver==0.0.4') result = script.pip('install', 'django-devserver==0.0.4')
devserver_folder = script.site_packages / 'devserver' devserver_folder = script.site_packages / 'devserver'
egg_info_folder = ( dist_info_folder = (
script.site_packages / script.site_packages /
'django_devserver-0.0.4-py{pyversion}.egg-info'.format(**globals()) 'django_devserver-0.0.4.dist-info'
) )
result.did_create(devserver_folder) result.did_create(devserver_folder)
result.did_create(egg_info_folder) result.did_create(dist_info_folder)
def test_install_package_with_target(script): def test_install_package_with_target(script, with_wheel):
""" """
Test installing a package using pip install --target Test installing a package using pip install --target
""" """
@ -863,10 +871,11 @@ def test_install_package_with_target(script):
result = script.pip_install_local('--upgrade', '-t', result = script.pip_install_local('--upgrade', '-t',
target_dir, "simple==2.0") target_dir, "simple==2.0")
result.did_update(Path('scratch') / 'target' / 'simple') result.did_update(Path('scratch') / 'target' / 'simple')
egg_folder = ( dist_info_folder = (
Path('scratch') / 'target' / Path('scratch') / 'target' /
'simple-2.0-py{pyversion}.egg-info'.format(**globals())) 'simple-2.0.dist-info'
result.did_create(egg_folder) )
result.did_create(dist_info_folder)
# Test install and upgrade of single-module package # Test install and upgrade of single-module package
result = script.pip_install_local('-t', target_dir, 'singlemodule==0.0.0') result = script.pip_install_local('-t', target_dir, 'singlemodule==0.0.0')
@ -990,7 +999,7 @@ def test_install_with_target_and_scripts_no_warning(script, with_wheel):
assert "--no-warn-script-location" not in result.stderr, str(result) assert "--no-warn-script-location" not in result.stderr, str(result)
def test_install_package_with_root(script, data): def test_install_package_with_root(script, data, with_wheel):
""" """
Test installing a package using pip install --root Test installing a package using pip install --root
""" """
@ -1001,7 +1010,7 @@ def test_install_package_with_root(script, data):
) )
normal_install_path = ( normal_install_path = (
script.base_path / script.site_packages / script.base_path / script.site_packages /
'simple-1.0-py{pyversion}.egg-info'.format(**globals()) 'simple-1.0.dist-info'
) )
# use distutils to change the root exactly how the --root option does it # use distutils to change the root exactly how the --root option does it
from distutils.util import change_root from distutils.util import change_root
@ -1029,6 +1038,7 @@ def test_install_package_with_prefix(script, data):
rel_prefix_path = script.scratch / 'prefix' rel_prefix_path = script.scratch / 'prefix'
install_path = ( install_path = (
distutils.sysconfig.get_python_lib(prefix=rel_prefix_path) / distutils.sysconfig.get_python_lib(prefix=rel_prefix_path) /
# we still test for egg-info because no-binary implies setup.py install
'simple-1.0-py{}.egg-info'.format(pyversion) 'simple-1.0-py{}.egg-info'.format(pyversion)
) )
result.did_create(install_path) result.did_create(install_path)
@ -1109,7 +1119,7 @@ def test_install_package_with_latin1_setup(script, data):
script.pip('install', to_install) script.pip('install', to_install)
def test_url_req_case_mismatch_no_index(script, data): def test_url_req_case_mismatch_no_index(script, data, with_wheel):
""" """
tar ball url requirements (with no egg fragment), that happen to have upper tar ball url requirements (with no egg fragment), that happen to have upper
case project names, should be considered equal to later requirements that case project names, should be considered equal to later requirements that
@ -1124,15 +1134,15 @@ def test_url_req_case_mismatch_no_index(script, data):
) )
# only Upper-1.0.tar.gz should get installed. # only Upper-1.0.tar.gz should get installed.
egg_folder = script.site_packages / \ dist_info_folder = script.site_packages / \
'Upper-1.0-py{pyversion}.egg-info'.format(**globals()) 'Upper-1.0.dist-info'
result.did_create(egg_folder) result.did_create(dist_info_folder)
egg_folder = script.site_packages / \ dist_info_folder = script.site_packages / \
'Upper-2.0-py{pyversion}.egg-info'.format(**globals()) 'Upper-2.0.dist-info'
result.did_not_create(egg_folder) result.did_not_create(dist_info_folder)
def test_url_req_case_mismatch_file_index(script, data): def test_url_req_case_mismatch_file_index(script, data, with_wheel):
""" """
tar ball url requirements (with no egg fragment), that happen to have upper tar ball url requirements (with no egg fragment), that happen to have upper
case project names, should be considered equal to later requirements that case project names, should be considered equal to later requirements that
@ -1153,15 +1163,15 @@ def test_url_req_case_mismatch_file_index(script, data):
) )
# only Upper-1.0.tar.gz should get installed. # only Upper-1.0.tar.gz should get installed.
egg_folder = script.site_packages / \ dist_info_folder = script.site_packages / \
'Dinner-1.0-py{pyversion}.egg-info'.format(**globals()) 'Dinner-1.0.dist-info'
result.did_create(egg_folder) result.did_create(dist_info_folder)
egg_folder = script.site_packages / \ dist_info_folder = script.site_packages / \
'Dinner-2.0-py{pyversion}.egg-info'.format(**globals()) 'Dinner-2.0.dist-info'
result.did_not_create(egg_folder) result.did_not_create(dist_info_folder)
def test_url_incorrect_case_no_index(script, data): def test_url_incorrect_case_no_index(script, data, with_wheel):
""" """
Same as test_url_req_case_mismatch_no_index, except testing for the case Same as test_url_req_case_mismatch_no_index, except testing for the case
where the incorrect case is given in the name of the package to install where the incorrect case is given in the name of the package to install
@ -1172,15 +1182,15 @@ def test_url_incorrect_case_no_index(script, data):
) )
# only Upper-2.0.tar.gz should get installed. # only Upper-2.0.tar.gz should get installed.
egg_folder = script.site_packages / \ dist_info_folder = script.site_packages / \
'Upper-1.0-py{pyversion}.egg-info'.format(**globals()) 'Upper-1.0.dist-info'
result.did_not_create(egg_folder) result.did_not_create(dist_info_folder)
egg_folder = script.site_packages / \ dist_info_folder = script.site_packages / \
'Upper-2.0-py{pyversion}.egg-info'.format(**globals()) 'Upper-2.0.dist-info'
result.did_create(egg_folder) result.did_create(dist_info_folder)
def test_url_incorrect_case_file_index(script, data): def test_url_incorrect_case_file_index(script, data, with_wheel):
""" """
Same as test_url_req_case_mismatch_file_index, except testing for the case Same as test_url_req_case_mismatch_file_index, except testing for the case
where the incorrect case is given in the name of the package to install where the incorrect case is given in the name of the package to install
@ -1192,12 +1202,12 @@ def test_url_incorrect_case_file_index(script, data):
) )
# only Upper-2.0.tar.gz should get installed. # only Upper-2.0.tar.gz should get installed.
egg_folder = script.site_packages / \ dist_info_folder = script.site_packages / \
'Dinner-1.0-py{pyversion}.egg-info'.format(**globals()) 'Dinner-1.0.dist-info'
result.did_not_create(egg_folder) result.did_not_create(dist_info_folder)
egg_folder = script.site_packages / \ dist_info_folder = script.site_packages / \
'Dinner-2.0-py{pyversion}.egg-info'.format(**globals()) 'Dinner-2.0.dist-info'
result.did_create(egg_folder) result.did_create(dist_info_folder)
# Should show index-url location in output # Should show index-url location in output
assert "Looking in indexes: " in result.stdout assert "Looking in indexes: " in result.stdout

View File

@ -3,10 +3,8 @@ import textwrap
from pip._vendor.six.moves.urllib import parse as urllib_parse from pip._vendor.six.moves.urllib import parse as urllib_parse
from tests.lib import pyversion
def test_find_links_relative_path(script, data, with_wheel):
def test_find_links_relative_path(script, data):
"""Test find-links as a relative path.""" """Test find-links as a relative path."""
result = script.pip( result = script.pip(
'install', 'install',
@ -16,15 +14,15 @@ def test_find_links_relative_path(script, data):
'packages/', 'packages/',
cwd=data.root, cwd=data.root,
) )
egg_info_folder = ( dist_info_folder = (
script.site_packages / 'parent-0.1-py{}.egg-info'.format(pyversion) script.site_packages / 'parent-0.1.dist-info'
) )
initools_folder = script.site_packages / 'parent' initools_folder = script.site_packages / 'parent'
result.did_create(egg_info_folder) result.did_create(dist_info_folder)
result.did_create(initools_folder) result.did_create(initools_folder)
def test_find_links_requirements_file_relative_path(script, data): def test_find_links_requirements_file_relative_path(script, data, with_wheel):
"""Test find-links as a relative path to a reqs file.""" """Test find-links as a relative path to a reqs file."""
script.scratch_path.joinpath("test-req.txt").write_text(textwrap.dedent(""" script.scratch_path.joinpath("test-req.txt").write_text(textwrap.dedent("""
--no-index --no-index
@ -37,27 +35,27 @@ def test_find_links_requirements_file_relative_path(script, data):
script.scratch_path / "test-req.txt", script.scratch_path / "test-req.txt",
cwd=data.root, cwd=data.root,
) )
egg_info_folder = ( dist_info_folder = (
script.site_packages / 'parent-0.1-py{}.egg-info'.format(pyversion) script.site_packages / 'parent-0.1.dist-info'
) )
initools_folder = script.site_packages / 'parent' initools_folder = script.site_packages / 'parent'
result.did_create(egg_info_folder) result.did_create(dist_info_folder)
result.did_create(initools_folder) result.did_create(initools_folder)
def test_install_from_file_index_hash_link(script, data): def test_install_from_file_index_hash_link(script, data, with_wheel):
""" """
Test that a pkg can be installed from a file:// index using a link with a Test that a pkg can be installed from a file:// index using a link with a
hash hash
""" """
result = script.pip('install', '-i', data.index_url(), 'simple==1.0') result = script.pip('install', '-i', data.index_url(), 'simple==1.0')
egg_info_folder = ( dist_info_folder = (
script.site_packages / 'simple-1.0-py{}.egg-info'.format(pyversion) script.site_packages / 'simple-1.0.dist-info'
) )
result.did_create(egg_info_folder) result.did_create(dist_info_folder)
def test_file_index_url_quoting(script, data): def test_file_index_url_quoting(script, data, with_wheel):
""" """
Test url quoting of file index url with a space Test url quoting of file index url with a space
""" """
@ -67,5 +65,5 @@ def test_file_index_url_quoting(script, data):
) )
result.did_create(script.site_packages / 'simple') result.did_create(script.site_packages / 'simple')
result.did_create( result.did_create(
script.site_packages / 'simple-1.0-py{}.egg-info'.format(pyversion) script.site_packages / 'simple-1.0.dist-info'
) )

View File

@ -10,7 +10,6 @@ from tests.lib import (
create_basic_wheel_for_package, create_basic_wheel_for_package,
need_svn, need_svn,
path_to_url, path_to_url,
pyversion,
requirements_file, requirements_file,
) )
from tests.lib.local_repos import local_checkout from tests.lib.local_repos import local_checkout
@ -63,7 +62,7 @@ def arg_recording_sdist_maker(script):
@pytest.mark.network @pytest.mark.network
def test_requirements_file(script): def test_requirements_file(script, with_wheel):
""" """
Test installing from a requirements file. Test installing from a requirements file.
@ -78,12 +77,12 @@ def test_requirements_file(script):
'install', '-r', script.scratch_path / 'initools-req.txt' 'install', '-r', script.scratch_path / 'initools-req.txt'
) )
result.did_create( result.did_create(
script.site_packages / 'INITools-0.2-py{}.egg-info'.format(pyversion) script.site_packages / 'INITools-0.2.dist-info'
) )
result.did_create(script.site_packages / 'initools') result.did_create(script.site_packages / 'initools')
assert result.files_created[script.site_packages / other_lib_name].dir assert result.files_created[script.site_packages / other_lib_name].dir
fn = '{}-{}-py{}.egg-info'.format( fn = '{}-{}.dist-info'.format(
other_lib_name, other_lib_version, pyversion) other_lib_name, other_lib_version)
assert result.files_created[script.site_packages / fn].dir assert result.files_created[script.site_packages / fn].dir
@ -113,15 +112,17 @@ def test_schema_check_in_requirements_file(script):
("embedded_rel_path", False), ("embedded_rel_path", False),
("embedded_rel_path", True), ("embedded_rel_path", True),
]) ])
def test_relative_requirements_file(script, data, test_type, editable): def test_relative_requirements_file(
script, data, test_type, editable, with_wheel
):
""" """
Test installing from a requirements file with a relative path. For path Test installing from a requirements file with a relative path. For path
URLs, use an egg= definition. URLs, use an egg= definition.
""" """
egg_info_file = ( dist_info_folder = (
script.site_packages / script.site_packages /
'FSPkg-0.1.dev0-py{pyversion}.egg-info'.format(**globals()) 'FSPkg-0.1.dev0.dist-info'
) )
egg_link_file = ( egg_link_file = (
script.site_packages / 'FSPkg.egg-link' script.site_packages / 'FSPkg.egg-link'
@ -148,7 +149,7 @@ def test_relative_requirements_file(script, data, test_type, editable):
script.scratch_path) as reqs_file: script.scratch_path) as reqs_file:
result = script.pip('install', '-vvv', '-r', reqs_file.name, result = script.pip('install', '-vvv', '-r', reqs_file.name,
cwd=script.scratch_path) cwd=script.scratch_path)
result.did_create(egg_info_file) result.did_create(dist_info_folder)
result.did_create(package_folder) result.did_create(package_folder)
else: else:
with requirements_file('-e ' + req_path + '\n', with requirements_file('-e ' + req_path + '\n',
@ -160,7 +161,7 @@ def test_relative_requirements_file(script, data, test_type, editable):
@pytest.mark.network @pytest.mark.network
@need_svn @need_svn
def test_multiple_requirements_files(script, tmpdir): def test_multiple_requirements_files(script, tmpdir, with_wheel):
""" """
Test installing from multiple nested requirements files. Test installing from multiple nested requirements files.
@ -184,8 +185,7 @@ def test_multiple_requirements_files(script, tmpdir):
'install', '-r', script.scratch_path / 'initools-req.txt' 'install', '-r', script.scratch_path / 'initools-req.txt'
) )
assert result.files_created[script.site_packages / other_lib_name].dir assert result.files_created[script.site_packages / other_lib_name].dir
fn = '{other_lib_name}-{other_lib_version}-py{pyversion}.egg-info'.format( fn = '{other_lib_name}-{other_lib_version}.dist-info'.format(**locals())
pyversion=pyversion, **locals())
assert result.files_created[script.site_packages / fn].dir assert result.files_created[script.site_packages / fn].dir
result.did_create(script.venv / 'src' / 'initools') result.did_create(script.venv / 'src' / 'initools')

View File

@ -38,7 +38,8 @@ def test_invalid_upgrade_strategy_causes_error(script):
def test_only_if_needed_does_not_upgrade_deps_when_satisfied( def test_only_if_needed_does_not_upgrade_deps_when_satisfied(
script, script,
use_new_resolver use_new_resolver,
with_wheel
): ):
""" """
It doesn't upgrade a dependency if it already satisfies the requirements. It doesn't upgrade a dependency if it already satisfies the requirements.
@ -50,13 +51,11 @@ def test_only_if_needed_does_not_upgrade_deps_when_satisfied(
) )
assert ( assert (
(script.site_packages / 'require_simple-1.0-py{pyversion}.egg-info' (script.site_packages / 'require_simple-1.0.dist-info')
.format(**globals()))
not in result.files_deleted not in result.files_deleted
), "should have installed require_simple==1.0" ), "should have installed require_simple==1.0"
assert ( assert (
(script.site_packages / 'simple-2.0-py{pyversion}.egg-info' (script.site_packages / 'simple-2.0.dist-info')
.format(**globals()))
not in result.files_deleted not in result.files_deleted
), "should not have uninstalled simple==2.0" ), "should not have uninstalled simple==2.0"
@ -68,7 +67,9 @@ def test_only_if_needed_does_not_upgrade_deps_when_satisfied(
), "did not print correct message for not-upgraded requirement" ), "did not print correct message for not-upgraded requirement"
def test_only_if_needed_does_upgrade_deps_when_no_longer_satisfied(script): def test_only_if_needed_does_upgrade_deps_when_no_longer_satisfied(
script, with_wheel
):
""" """
It does upgrade a dependency if it no longer satisfies the requirements. It does upgrade a dependency if it no longer satisfies the requirements.
@ -79,25 +80,26 @@ def test_only_if_needed_does_upgrade_deps_when_no_longer_satisfied(script):
) )
assert ( assert (
(script.site_packages / 'require_simple-1.0-py{pyversion}.egg-info' (script.site_packages / 'require_simple-1.0.dist-info')
.format(**globals()))
not in result.files_deleted not in result.files_deleted
), "should have installed require_simple==1.0" ), "should have installed require_simple==1.0"
expected = ( expected = (
script.site_packages / script.site_packages /
'simple-3.0-py{pyversion}.egg-info'.format(**globals()) 'simple-3.0.dist-info'
) )
result.did_create(expected, message="should have installed simple==3.0") result.did_create(expected, message="should have installed simple==3.0")
expected = ( expected = (
script.site_packages / script.site_packages /
'simple-1.0-py{pyversion}.egg-info'.format(**globals()) 'simple-1.0.dist-info'
) )
assert ( assert (
expected in result.files_deleted expected in result.files_deleted
), "should have uninstalled simple==1.0" ), "should have uninstalled simple==1.0"
def test_eager_does_upgrade_dependecies_when_currently_satisfied(script): def test_eager_does_upgrade_dependecies_when_currently_satisfied(
script, with_wheel
):
""" """
It does upgrade a dependency even if it already satisfies the requirements. It does upgrade a dependency even if it already satisfies the requirements.
@ -109,17 +111,19 @@ def test_eager_does_upgrade_dependecies_when_currently_satisfied(script):
assert ( assert (
(script.site_packages / (script.site_packages /
'require_simple-1.0-py{pyversion}.egg-info'.format(**globals())) 'require_simple-1.0.dist-info')
not in result.files_deleted not in result.files_deleted
), "should have installed require_simple==1.0" ), "should have installed require_simple==1.0"
assert ( assert (
(script.site_packages / (script.site_packages /
'simple-2.0-py{pyversion}.egg-info'.format(**globals())) 'simple-2.0.dist-info')
in result.files_deleted in result.files_deleted
), "should have uninstalled simple==2.0" ), "should have uninstalled simple==2.0"
def test_eager_does_upgrade_dependecies_when_no_longer_satisfied(script): def test_eager_does_upgrade_dependecies_when_no_longer_satisfied(
script, with_wheel
):
""" """
It does upgrade a dependency if it no longer satisfies the requirements. It does upgrade a dependency if it no longer satisfies the requirements.
@ -130,24 +134,21 @@ def test_eager_does_upgrade_dependecies_when_no_longer_satisfied(script):
) )
assert ( assert (
(script.site_packages / (script.site_packages / 'require_simple-1.0.dist-info')
'require_simple-1.0-py{pyversion}.egg-info'.format(**globals()))
not in result.files_deleted not in result.files_deleted
), "should have installed require_simple==1.0" ), "should have installed require_simple==1.0"
result.did_create( result.did_create(
script.site_packages / script.site_packages / 'simple-3.0.dist-info',
'simple-3.0-py{pyversion}.egg-info'.format(**globals()),
message="should have installed simple==3.0" message="should have installed simple==3.0"
) )
assert ( assert (
script.site_packages / script.site_packages / 'simple-1.0.dist-info'
'simple-1.0-py{pyversion}.egg-info'.format(**globals())
in result.files_deleted in result.files_deleted
), "should have uninstalled simple==1.0" ), "should have uninstalled simple==1.0"
@pytest.mark.network @pytest.mark.network
def test_upgrade_to_specific_version(script): def test_upgrade_to_specific_version(script, with_wheel):
""" """
It does upgrade to specific version requested. It does upgrade to specific version requested.
@ -158,18 +159,16 @@ def test_upgrade_to_specific_version(script):
'pip install with specific version did not upgrade' 'pip install with specific version did not upgrade'
) )
assert ( assert (
script.site_packages / 'INITools-0.1-py{pyversion}.egg-info' script.site_packages / 'INITools-0.1.dist-info'
.format(**globals())
in result.files_deleted in result.files_deleted
) )
result.did_create( result.did_create(
script.site_packages / 'INITools-0.2-py{pyversion}.egg-info' script.site_packages / 'INITools-0.2.dist-info'
.format(**globals())
) )
@pytest.mark.network @pytest.mark.network
def test_upgrade_if_requested(script): def test_upgrade_if_requested(script, with_wheel):
""" """
And it does upgrade if requested. And it does upgrade if requested.
@ -179,7 +178,7 @@ def test_upgrade_if_requested(script):
assert result.files_created, 'pip install --upgrade did not upgrade' assert result.files_created, 'pip install --upgrade did not upgrade'
result.did_not_create( result.did_not_create(
script.site_packages / script.site_packages /
'INITools-0.1-py{pyversion}.egg-info'.format(**globals()) 'INITools-0.1.dist-info'
) )
@ -327,7 +326,7 @@ def test_uninstall_rollback(script, data):
@pytest.mark.network @pytest.mark.network
def test_should_not_install_always_from_cache(script): def test_should_not_install_always_from_cache(script, with_wheel):
""" """
If there is an old cached package, pip should download the newer version If there is an old cached package, pip should download the newer version
Related to issue #175 Related to issue #175
@ -337,16 +336,16 @@ def test_should_not_install_always_from_cache(script):
result = script.pip('install', 'INITools==0.1') result = script.pip('install', 'INITools==0.1')
result.did_not_create( result.did_not_create(
script.site_packages / script.site_packages /
'INITools-0.2-py{pyversion}.egg-info'.format(**globals()) 'INITools-0.2.dist-info'
) )
result.did_create( result.did_create(
script.site_packages / script.site_packages /
'INITools-0.1-py{pyversion}.egg-info'.format(**globals()) 'INITools-0.1.dist-info'
) )
@pytest.mark.network @pytest.mark.network
def test_install_with_ignoreinstalled_requested(script): def test_install_with_ignoreinstalled_requested(script, with_wheel):
""" """
Test old conflicting package is completely ignored Test old conflicting package is completely ignored
""" """
@ -356,11 +355,11 @@ def test_install_with_ignoreinstalled_requested(script):
# both the old and new metadata should be present. # both the old and new metadata should be present.
assert os.path.exists( assert os.path.exists(
script.site_packages_path / script.site_packages_path /
'INITools-0.1-py{pyversion}.egg-info'.format(**globals()) 'INITools-0.1.dist-info'
) )
assert os.path.exists( assert os.path.exists(
script.site_packages_path / script.site_packages_path /
'INITools-0.3-py{pyversion}.egg-info'.format(**globals()) 'INITools-0.3.dist-info'
) )

View File

@ -115,6 +115,7 @@ class Tests_UserSite:
'install', '--user', 'INITools==0.1', '--no-binary=:all:') 'install', '--user', 'INITools==0.1', '--no-binary=:all:')
# usersite has 0.1 # usersite has 0.1
# we still test for egg-info because no-binary implies setup.py install
egg_info_folder = ( egg_info_folder = (
script.user_site / script.user_site /
'INITools-0.1-py{pyversion}.egg-info'.format(**globals()) 'INITools-0.1-py{pyversion}.egg-info'.format(**globals())
@ -142,6 +143,7 @@ class Tests_UserSite:
'install', '--user', 'INITools==0.1', '--no-binary=:all:') 'install', '--user', 'INITools==0.1', '--no-binary=:all:')
# usersite has 0.1 # usersite has 0.1
# we still test for egg-info because no-binary implies setup.py install
egg_info_folder = ( egg_info_folder = (
script.user_site / script.user_site /
'INITools-0.1-py{pyversion}.egg-info'.format(**globals()) 'INITools-0.1-py{pyversion}.egg-info'.format(**globals())
@ -173,6 +175,7 @@ class Tests_UserSite:
'install', '--user', '--upgrade', 'INITools', '--no-binary=:all:') 'install', '--user', '--upgrade', 'INITools', '--no-binary=:all:')
# usersite has 0.3.1 # usersite has 0.3.1
# we still test for egg-info because no-binary implies setup.py install
egg_info_folder = ( egg_info_folder = (
script.user_site / script.user_site /
'INITools-0.3.1-py{pyversion}.egg-info'.format(**globals()) 'INITools-0.3.1-py{pyversion}.egg-info'.format(**globals())
@ -207,6 +210,7 @@ class Tests_UserSite:
'install', '--user', 'INITools==0.1', '--no-binary=:all:') 'install', '--user', 'INITools==0.1', '--no-binary=:all:')
# usersite has 0.1 # usersite has 0.1
# we still test for egg-info because no-binary implies setup.py install
egg_info_folder = ( egg_info_folder = (
script.user_site / script.user_site /
'INITools-0.1-py{pyversion}.egg-info'.format(**globals()) 'INITools-0.1-py{pyversion}.egg-info'.format(**globals())

View File

@ -160,7 +160,7 @@ def test_install_editable_from_git_with_https(script, tmpdir):
@pytest.mark.network @pytest.mark.network
def test_install_noneditable_git(script, tmpdir): def test_install_noneditable_git(script, tmpdir, with_wheel):
""" """
Test installing from a non-editable git URL with a given tag. Test installing from a non-editable git URL with a given tag.
""" """
@ -169,14 +169,14 @@ def test_install_noneditable_git(script, tmpdir):
'git+https://github.com/pypa/pip-test-package.git' 'git+https://github.com/pypa/pip-test-package.git'
'@0.1.1#egg=pip-test-package' '@0.1.1#egg=pip-test-package'
) )
egg_info_folder = ( dist_info_folder = (
script.site_packages / script.site_packages /
'pip_test_package-0.1.1-py{pyversion}.egg-info'.format(**globals()) 'pip_test_package-0.1.1.dist-info'
) )
result.assert_installed('piptestpackage', result.assert_installed('piptestpackage',
without_egg_link=True, without_egg_link=True,
editable=False) editable=False)
result.did_create(egg_info_folder) result.did_create(dist_info_folder)
def test_git_with_sha1_revisions(script): def test_git_with_sha1_revisions(script):

View File

@ -340,8 +340,8 @@ def test_install_user_wheel(script, shared_data, with_wheel, tmpdir):
'install', 'has.script==1.0', '--user', '--no-index', 'install', 'has.script==1.0', '--user', '--no-index',
'--find-links', tmpdir, '--find-links', tmpdir,
) )
egg_info_folder = script.user_site / 'has.script-1.0.dist-info' dist_info_folder = script.user_site / 'has.script-1.0.dist-info'
result.did_create(egg_info_folder) result.did_create(dist_info_folder)
script_file = script.user_bin / 'script.py' script_file = script.user_bin / 'script.py'
result.did_create(script_file) result.did_create(script_file)

View File

@ -43,6 +43,7 @@ class Tests_UninstallUserSite:
assert_all_changes(result2, result3, [script.venv / 'build', 'cache']) assert_all_changes(result2, result3, [script.venv / 'build', 'cache'])
# site still has 0.2 (can't look in result1; have to check) # site still has 0.2 (can't look in result1; have to check)
# keep checking for egg-info because no-binary implies setup.py install
egg_info_folder = ( egg_info_folder = (
script.base_path / script.site_packages / script.base_path / script.site_packages /
'pip_test_package-0.1-py{pyversion}.egg-info'.format(**globals()) 'pip_test_package-0.1-py{pyversion}.egg-info'.format(**globals())