Skip to content

Commit

Permalink
Add test to compare install reports of direct...
Browse files Browse the repository at this point in the history
installs and those from index. is_direct and url
are expected to differ, everything else should be equal.

At least requested_extras and hashes are not, see
#11946
  • Loading branch information
phaer committed Apr 11, 2023
1 parent 55f1251 commit 31f97d4
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions tests/functional/test_install_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,62 @@ def test_install_report_index(script: PipTestEnvironment, tmp_path: Path) -> Non
assert "requires_dist" in paste_report["metadata"]


@pytest.mark.network
def test_install_report_direct_index(script: PipTestEnvironment, shared_data: TestData, tmp_path: Path) -> None:
"""Compare report for sdist obtained via direct url and sdist obtained from index"""
report_direct_path = tmp_path / "report.json"
package = shared_data.root / "packages" / "mypy-0.782-py3-none-any.whl"
script.pip(
"install",
"--dry-run",
f"{package}[dmypy]",
"--report",
str(report_direct_path),
)
report_direct = json.loads(report_direct_path.read_text())

report_index_path = tmp_path / "report.json"
script.pip(
"install",
"--dry-run",
f"mypy[dmypy]==0.782",
"--report",
str(report_index_path),
)
report_index = json.loads(report_index_path.read_text())

assert len(report_direct["install"]) == len(report_index["install"])
for (direct, index) in zip(report_direct["install"], report_index["install"]):
name = direct['metadata']['name']
assert name == index['metadata']['name']
if name != "mypy":
continue

assert direct["is_direct"] == True
assert index["is_direct"] == False
del direct["is_direct"]
del index["is_direct"]

assert direct["download_info"]["url"].startswith("file://")
assert index["download_info"]["url"].startswith("https://")
del direct["download_info"]["url"]
del index ["download_info"]["url"]

# TODO: Is this intended behaviour? 'hash' is equal, 'hashes' is missing
# in direct installs.
# assert "hashes" not in direct["download_info"]["archive_info"]
# assert "hashes" in index["download_info"]["archive_info"]
# del index["download_info"]["archive_info"]["hashes"]

# TODO: this would be required to pass with pip 23.0.1, see
# https://github.com/pypa/pip/issues/11946
# assert "requested_extras" not in direct
# assert index["requested_extras"] == ['dmypy']
# del index["requested_extras"]

assert direct == index


@pytest.mark.network
def test_install_report_vcs_and_wheel_cache(
script: PipTestEnvironment, tmp_path: Path
Expand Down

0 comments on commit 31f97d4

Please sign in to comment.