mirror of https://github.com/pypa/pip
Add is_yanked to installation report
This commit is contained in:
parent
0778c1c153
commit
361b02bce0
|
@ -0,0 +1 @@
|
|||
Add ``is_yanked`` boolean entry to the installation report (``--report``) to indicate whether the requirement was yanked from the index, but still was selected by pip conform PEP 592.
|
|
@ -23,6 +23,9 @@ class InstallationReport:
|
|||
# includes editable requirements), and false if the requirement was
|
||||
# downloaded from a PEP 503 index or --find-links.
|
||||
"is_direct": ireq.is_direct,
|
||||
# is_yanked is true if the requirement was yanked from the index, but
|
||||
# still was selected by pip conform PEP 592
|
||||
"is_yanked": ireq.link.is_yanked if ireq.link else False,
|
||||
# requested is true if the requirement was specified by the user (aka
|
||||
# top level requirement), and false if it was installed as a dependency of a
|
||||
# requirement. https://peps.python.org/pep-0376/#requested
|
||||
|
|
|
@ -64,6 +64,59 @@ def test_install_report_dep(
|
|||
assert _install_dict(report)["simple"]["requested"] is False
|
||||
|
||||
|
||||
def test_yanked_version(
|
||||
script: PipTestEnvironment, data: TestData, tmp_path: Path
|
||||
) -> None:
|
||||
"""
|
||||
Test is_yanked is True when explicitly requesting a yanked package.
|
||||
Yanked files are always ignored, unless they are the only file that
|
||||
matches a version specifier that "pins" to an exact version (PEP 592).
|
||||
"""
|
||||
report_path = tmp_path / "report.json"
|
||||
script.pip(
|
||||
"install",
|
||||
"simple==3.0",
|
||||
"--index-url",
|
||||
data.index_url("yanked"),
|
||||
"--dry-run",
|
||||
"--report",
|
||||
str(report_path),
|
||||
allow_stderr_warning=True,
|
||||
)
|
||||
report = json.loads(report_path.read_text())
|
||||
simple_report = _install_dict(report)["simple"]
|
||||
assert simple_report["requested"] is True
|
||||
assert simple_report["is_direct"] is False
|
||||
assert simple_report["is_yanked"] is True
|
||||
assert simple_report["metadata"]["version"] == "3.0"
|
||||
|
||||
|
||||
def test_skipped_yanked_version(
|
||||
script: PipTestEnvironment, data: TestData, tmp_path: Path
|
||||
) -> None:
|
||||
"""
|
||||
Test is_yanked is False when not explicitly requesting a yanked package.
|
||||
Yanked files are always ignored, unless they are the only file that
|
||||
matches a version specifier that "pins" to an exact version (PEP 592).
|
||||
"""
|
||||
report_path = tmp_path / "report.json"
|
||||
script.pip(
|
||||
"install",
|
||||
"simple",
|
||||
"--index-url",
|
||||
data.index_url("yanked"),
|
||||
"--dry-run",
|
||||
"--report",
|
||||
str(report_path),
|
||||
)
|
||||
report = json.loads(report_path.read_text())
|
||||
simple_report = _install_dict(report)["simple"]
|
||||
assert simple_report["requested"] is True
|
||||
assert simple_report["is_direct"] is False
|
||||
assert simple_report["is_yanked"] is False
|
||||
assert simple_report["metadata"]["version"] == "2.0"
|
||||
|
||||
|
||||
@pytest.mark.network
|
||||
def test_install_report_index(script: PipTestEnvironment, tmp_path: Path) -> None:
|
||||
"""Test report for sdist obtained from index."""
|
||||
|
|
Loading…
Reference in New Issue