Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
f9366da
Remove setup.py develop code path
sbidoul Mar 8, 2025
cafa715
Remove legacy editable tests
sbidoul May 10, 2025
aed7024
Refactor get_created_direct_url test
sbidoul May 18, 2025
8add656
Rework PipTestResult for detection of modern editables
sbidoul May 18, 2025
50804ff
Update tests that were looking for egg-link files to detect editables
sbidoul May 10, 2025
85bb55a
Test there is no fallback when backend has no PEP 660
sbidoul Sep 27, 2025
3cc9e6b
Update uninstall tests that depend on legacy install methods
sbidoul Sep 27, 2025
4eda5e4
Update pip show test that depends on legacy install method
sbidoul Sep 27, 2025
674df32
Remove non PEP 517 code paths
sbidoul Sep 28, 2025
90fa35d
Remove --use-pep517 option test
sbidoul Sep 28, 2025
0dbd25e
Remove --no-use-pep517 test
sbidoul Sep 28, 2025
05e53ef
Update creation of test package that must fail building
sbidoul Sep 28, 2025
fe02d65
Run unit tests with no build isolation
sbidoul Sep 28, 2025
873a1c5
Remove tests that exercise --global-option
sbidoul Sep 28, 2025
017d5e6
Rework test that needed --global-option to use --config-setting
sbidoul Sep 28, 2025
0e07ba2
Test install pip without build isolation
sbidoul Sep 28, 2025
16b2601
Remove legacy 'setup.py clean' tests
sbidoul Sep 28, 2025
8fec3f0
Add --no-build-isolation to tests
sbidoul Sep 28, 2025
b3871c6
Add news
sbidoul Sep 27, 2025
6feecc2
Fix and expand PEP 660 detection
sbidoul Sep 28, 2025
893ab4b
Remove a few more obsolete pep517 things from the test suite
sbidoul Sep 29, 2025
5a17132
Docs: reflect removal of direct setup.py invocations
sbidoul Oct 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rework PipTestResult for detection of modern editables
  • Loading branch information
sbidoul committed Oct 21, 2025
commit 8add656f952352c86259bc305d4e17b539e4f808
8 changes: 6 additions & 2 deletions tests/functional/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,9 @@ def test_install_editable_uninstalls_existing(
to_install = data.packages.joinpath("pip_test_package-0.1.tar.gz")
result = script.pip_install_local(to_install)
assert "Successfully installed pip-test-package" in result.stdout
result.assert_installed("piptestpackage", editable=False)
result.assert_installed(
"piptestpackage", dist_name="pip-test-package", editable=False
)

result = script.pip(
"install",
Expand All @@ -449,7 +451,9 @@ def test_install_editable_uninstalls_existing(
)
),
)
result.assert_installed("pip-test-package", with_files=[".git"])
result.assert_installed(
"piptestpackage", dist_name="pip-test-package", with_files=[".git"]
)
assert "Found existing installation: pip-test-package 0.1" in result.stdout
assert "Uninstalling pip-test-package-" in result.stdout
assert "Successfully uninstalled pip-test-package" in result.stdout
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/test_install_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def test_install_subversion_usersite_editable_with_distribute(
)
),
)
result.assert_installed("INITools", use_user_site=True)
result.assert_installed("INITools")

def test_install_from_current_directory_into_usersite(
self, script: PipTestEnvironment, data: TestData
Expand Down
11 changes: 7 additions & 4 deletions tests/functional/test_install_vcs_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ def test_install_editable_from_git_with_https(
url_path = "pypa/pip-test-package.git"
local_url = _github_checkout(url_path, tmpdir, egg="pip-test-package")
result = script.pip("install", "-e", local_url)
result.assert_installed("pip-test-package", with_files=[".git"])
result.assert_installed(
"piptestpackage", dist_name="pip-test-package", with_files=[".git"]
)


@pytest.mark.network
Expand All @@ -193,11 +195,12 @@ def test_install_noneditable_git(script: PipTestEnvironment) -> None:
"""
result = script.pip(
"install",
"git+https://github.com/pypa/pip-test-package.git"
"@0.1.1#egg=pip-test-package",
"git+https://github.com/pypa/[email protected]#egg=pip-test-package",
)
dist_info_folder = script.site_packages / "pip_test_package-0.1.1.dist-info"
result.assert_installed("piptestpackage", without_egg_link=True, editable=False)
result.assert_installed(
"piptestpackage", dist_name="pip-test-package", editable=False
)
result.did_create(dist_info_folder)


Expand Down
6 changes: 3 additions & 3 deletions tests/functional/test_install_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ def test_install_from_future_wheel_version(

result = script.pip("install", package, "--no-index", expect_error=True)
with pytest.raises(TestFailure):
result.assert_installed("futurewheel", without_egg_link=True, editable=False)
result.assert_installed("futurewheel", editable=False)

package = make_wheel_with_file(
name="futurewheel",
version="1.9",
wheel_metadata_updates={"Wheel-Version": "1.9"},
).save_to_dir(tmpdir)
result = script.pip("install", package, "--no-index", expect_stderr=True)
result.assert_installed("futurewheel", without_egg_link=True, editable=False)
result.assert_installed("futurewheel", editable=False)


@pytest.mark.parametrize(
Expand All @@ -67,7 +67,7 @@ def test_install_from_broken_wheel(
package = data.packages.joinpath(wheel_name)
result = script.pip("install", package, "--no-index", expect_error=True)
with pytest.raises(TestFailure):
result.assert_installed("futurewheel", without_egg_link=True, editable=False)
result.assert_installed("futurewheel", editable=False)


def test_basic_install_from_wheel(
Expand Down
82 changes: 22 additions & 60 deletions tests/lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
from pip._internal.models.selection_prefs import SelectionPreferences
from pip._internal.models.target_python import TargetPython
from pip._internal.network.session import PipSession
from pip._internal.utils.egg_link import _egg_link_names

from tests.lib.venv import VirtualEnvironment
from tests.lib.wheel import make_wheel
Expand Down Expand Up @@ -294,12 +293,6 @@ def files_updated(self) -> FoundFiles:
def files_deleted(self) -> FoundFiles:
return FoundFiles(self._impl.files_deleted)

def _get_egg_link_path_created(self, egg_link_paths: list[str]) -> str | None:
for egg_link_path in egg_link_paths:
if egg_link_path in self.files_created:
return egg_link_path
return None

def get_created_direct_url_path(self, pkg: str) -> Path | None:
dist_info_prefix = canonicalize_name(pkg).replace("-", "_") + "-"
for filename in self.files_created:
Expand All @@ -321,81 +314,50 @@ def get_created_direct_url(self, pkg: str) -> DirectUrl | None:
def assert_installed(
self,
pkg_name: str,
*,
dist_name: str | None = None,
editable: bool = True,
editable_vcs: bool = True,
with_files: list[str] | None = None,
without_files: list[str] | None = None,
without_egg_link: bool = False,
use_user_site: bool = False,
sub_dir: str | None = None,
) -> None:
if dist_name is None:
dist_name = pkg_name
with_files = with_files or []
without_files = without_files or []
e = self.test_env

if editable:
pkg_dir = e.venv / "src" / canonicalize_name(pkg_name)
if editable and editable_vcs:
pkg_dir = e.venv / "src" / canonicalize_name(dist_name)
# If package was installed in a sub directory
if sub_dir:
pkg_dir = pkg_dir / sub_dir
elif editable and not editable_vcs:
pkg_dir = None
assert not with_files
assert not without_files
else:
without_egg_link = True
pkg_dir = e.site_packages / pkg_name

if use_user_site:
egg_link_paths = [
e.user_site / egg_link_name
for egg_link_name in _egg_link_names(pkg_name)
]
else:
egg_link_paths = [
e.site_packages / egg_link_name
for egg_link_name in _egg_link_names(pkg_name)
]

egg_link_path_created = self._get_egg_link_path_created(egg_link_paths)
if without_egg_link:
if egg_link_path_created:
direct_url = self.get_created_direct_url(dist_name)
if not editable:
if direct_url and direct_url.is_local_editable():
raise TestFailure(
f"unexpected egg link file created: {egg_link_path_created!r}\n"
"unexpected editable direct_url.json created: "
f"{self.get_created_direct_url_path(dist_name)!r}\n"
f"{self}"
)
else:
if not egg_link_path_created:
raise TestFailure(
f"expected egg link file missing: {egg_link_paths!r}\n{self}"
)

egg_link_file = self.files_created[egg_link_path_created]
egg_link_contents = egg_link_file.bytes.replace(os.linesep, "\n")

# FIXME: I don't understand why there's a trailing . here
if not (
egg_link_contents.endswith("\n.")
and egg_link_contents[:-2].endswith(os.fspath(pkg_dir))
):
expected_ending = f"{pkg_dir}\n."
if not direct_url or not direct_url.is_local_editable():
raise TestFailure(
textwrap.dedent(
f"""
Incorrect egg_link file {egg_link_file!r}
Expected ending: {expected_ending!r}
------- Actual contents -------
{egg_link_contents!r}
-------------------------------
"""
).strip()
f"{dist_name!r} not installed as editable: direct_url.json "
"not found or not editable\n"
f"{self.get_created_direct_url_path(dist_name)!r}\n"
f"{self}"
)

if use_user_site:
pth_file = e.user_site / "easy-install.pth"
else:
pth_file = e.site_packages / "easy-install.pth"

if (pth_file in self.files_updated) == without_egg_link:
maybe = "" if without_egg_link else "not "
raise TestFailure(f"{pth_file} unexpectedly {maybe}updated by install")

if (pkg_dir in self.files_created) == (os.curdir in without_files):
if pkg_dir and (pkg_dir in self.files_created) == (os.curdir in without_files):
maybe = "not " if os.curdir in without_files else ""
files = sorted(p.as_posix() for p in self.files_created)
raise TestFailure(
Expand Down