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
Refactor get_created_direct_url test
  • Loading branch information
sbidoul committed Oct 21, 2025
commit aed7024ec1c6defcaca538e0bc4ff926f6e7b135
3 changes: 1 addition & 2 deletions tests/functional/test_freeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
need_svn,
wheel,
)
from tests.lib.direct_url import get_created_direct_url_path
from tests.lib.venv import VirtualEnvironment

distribute_re = re.compile("^distribute==[0-9.]+\n", re.MULTILINE)
Expand Down Expand Up @@ -1039,7 +1038,7 @@ def test_freeze_pep610_editable(script: PipTestEnvironment) -> None:
"""
pkg_path = _create_test_package(script.scratch_path, name="testpkg")
result = script.pip("install", pkg_path)
direct_url_path = get_created_direct_url_path(result, "testpkg")
direct_url_path = result.get_created_direct_url_path("testpkg")
assert direct_url_path
# patch direct_url.json to simulate an editable install
with open(direct_url_path) as f:
Expand Down
11 changes: 5 additions & 6 deletions tests/functional/test_install_direct_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,19 @@
from pip._internal.models.direct_url import VcsInfo

from tests.lib import PipTestEnvironment, TestData, _create_test_package
from tests.lib.direct_url import get_created_direct_url


def test_install_find_links_no_direct_url(script: PipTestEnvironment) -> None:
result = script.pip_install_local("simple")
assert not get_created_direct_url(result, "simple")
assert not result.get_created_direct_url("simple")


def test_install_vcs_non_editable_direct_url(script: PipTestEnvironment) -> None:
pkg_path = _create_test_package(script.scratch_path, name="testpkg")
url = pkg_path.as_uri()
args = ["install", f"git+{url}#egg=testpkg"]
result = script.pip(*args)
direct_url = get_created_direct_url(result, "testpkg")
direct_url = result.get_created_direct_url("testpkg")
assert direct_url
assert direct_url.url == url
assert isinstance(direct_url.info, VcsInfo)
Expand All @@ -27,7 +26,7 @@ def test_install_archive_direct_url(script: PipTestEnvironment, data: TestData)
req = "simple @ " + data.packages.joinpath("simple-2.0.tar.gz").as_uri()
assert req.startswith("simple @ file://")
result = script.pip("install", req)
assert get_created_direct_url(result, "simple")
assert result.get_created_direct_url("simple")


@pytest.mark.network
Expand All @@ -39,7 +38,7 @@ def test_install_vcs_constraint_direct_url(script: PipTestEnvironment) -> None:
"#egg=pip-test-package"
)
result = script.pip("install", "pip-test-package", "-c", constraints_file)
assert get_created_direct_url(result, "pip_test_package")
assert result.get_created_direct_url("pip_test_package")


def test_install_vcs_constraint_direct_file_url(script: PipTestEnvironment) -> None:
Expand All @@ -48,4 +47,4 @@ def test_install_vcs_constraint_direct_file_url(script: PipTestEnvironment) -> N
constraints_file = script.scratch_path / "constraints.txt"
constraints_file.write_text(f"git+{url}#egg=testpkg")
result = script.pip("install", "testpkg", "-c", constraints_file)
assert get_created_direct_url(result, "testpkg")
assert result.get_created_direct_url("testpkg")
3 changes: 1 addition & 2 deletions tests/functional/test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
make_wheel,
wheel,
)
from tests.lib.direct_url import get_created_direct_url_path


@pytest.fixture(scope="session")
Expand Down Expand Up @@ -736,7 +735,7 @@ def test_list_pep610_editable(script: PipTestEnvironment) -> None:
"""
pkg_path = _create_test_package(script.scratch_path, name="testpkg")
result = script.pip("install", pkg_path)
direct_url_path = get_created_direct_url_path(result, "testpkg")
direct_url_path = result.get_created_direct_url_path("testpkg")
assert direct_url_path
# patch direct_url.json to simulate an editable install
with open(direct_url_path) as f:
Expand Down
7 changes: 3 additions & 4 deletions tests/functional/test_new_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
create_basic_wheel_for_package,
create_test_package_with_setup,
)
from tests.lib.direct_url import get_created_direct_url
from tests.lib.venv import VirtualEnvironment
from tests.lib.wheel import make_wheel

Expand Down Expand Up @@ -2155,9 +2154,9 @@ def test_new_resolver_direct_url_with_extras(
)

script.assert_installed(pkg1="1", pkg2="1", pkg3="1")
assert not get_created_direct_url(result, "pkg1")
assert get_created_direct_url(result, "pkg2")
assert not get_created_direct_url(result, "pkg3")
assert not result.get_created_direct_url("pkg1")
assert result.get_created_direct_url("pkg2")
assert not result.get_created_direct_url("pkg3")


def test_new_resolver_modifies_installed_incompatible(
Expand Down
20 changes: 20 additions & 0 deletions tests/lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from contextlib import contextmanager
from hashlib import sha256
from io import BytesIO, StringIO
from pathlib import Path
from textwrap import dedent
from typing import Any, AnyStr, Callable, Literal, Protocol, Union, cast
from urllib.request import pathname2url
Expand All @@ -28,6 +29,7 @@
from pip._internal.index.collector import LinkCollector
from pip._internal.index.package_finder import PackageFinder
from pip._internal.locations import get_major_minor_version
from pip._internal.models.direct_url import DIRECT_URL_METADATA_NAME, DirectUrl
from pip._internal.models.search_scope import SearchScope
from pip._internal.models.selection_prefs import SelectionPreferences
from pip._internal.models.target_python import TargetPython
Expand Down Expand Up @@ -298,6 +300,24 @@ def _get_egg_link_path_created(self, egg_link_paths: list[str]) -> str | None:
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:
if (
filename.name == DIRECT_URL_METADATA_NAME
and filename.parent.name.endswith(".dist-info")
and filename.parent.name.startswith(dist_info_prefix)
):
return self.test_env.base_path / filename
return None

def get_created_direct_url(self, pkg: str) -> DirectUrl | None:
direct_url_path = self.get_created_direct_url_path(pkg)
if direct_url_path:
with open(direct_url_path) as f:
return DirectUrl.from_json(f.read())
return None

def assert_installed(
self,
pkg_name: str,
Expand Down
27 changes: 0 additions & 27 deletions tests/lib/direct_url.py

This file was deleted.