Skip to content

Commit 31f97d4

Browse files
committed
Add test to compare install reports of direct...
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
1 parent 55f1251 commit 31f97d4

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

tests/functional/test_install_report.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,62 @@ def test_install_report_index(script: PipTestEnvironment, tmp_path: Path) -> Non
9292
assert "requires_dist" in paste_report["metadata"]
9393

9494

95+
@pytest.mark.network
96+
def test_install_report_direct_index(script: PipTestEnvironment, shared_data: TestData, tmp_path: Path) -> None:
97+
"""Compare report for sdist obtained via direct url and sdist obtained from index"""
98+
report_direct_path = tmp_path / "report.json"
99+
package = shared_data.root / "packages" / "mypy-0.782-py3-none-any.whl"
100+
script.pip(
101+
"install",
102+
"--dry-run",
103+
f"{package}[dmypy]",
104+
"--report",
105+
str(report_direct_path),
106+
)
107+
report_direct = json.loads(report_direct_path.read_text())
108+
109+
report_index_path = tmp_path / "report.json"
110+
script.pip(
111+
"install",
112+
"--dry-run",
113+
f"mypy[dmypy]==0.782",
114+
"--report",
115+
str(report_index_path),
116+
)
117+
report_index = json.loads(report_index_path.read_text())
118+
119+
assert len(report_direct["install"]) == len(report_index["install"])
120+
for (direct, index) in zip(report_direct["install"], report_index["install"]):
121+
name = direct['metadata']['name']
122+
assert name == index['metadata']['name']
123+
if name != "mypy":
124+
continue
125+
126+
assert direct["is_direct"] == True
127+
assert index["is_direct"] == False
128+
del direct["is_direct"]
129+
del index["is_direct"]
130+
131+
assert direct["download_info"]["url"].startswith("file://")
132+
assert index["download_info"]["url"].startswith("https://")
133+
del direct["download_info"]["url"]
134+
del index ["download_info"]["url"]
135+
136+
# TODO: Is this intended behaviour? 'hash' is equal, 'hashes' is missing
137+
# in direct installs.
138+
# assert "hashes" not in direct["download_info"]["archive_info"]
139+
# assert "hashes" in index["download_info"]["archive_info"]
140+
# del index["download_info"]["archive_info"]["hashes"]
141+
142+
# TODO: this would be required to pass with pip 23.0.1, see
143+
# https://github.com/pypa/pip/issues/11946
144+
# assert "requested_extras" not in direct
145+
# assert index["requested_extras"] == ['dmypy']
146+
# del index["requested_extras"]
147+
148+
assert direct == index
149+
150+
95151
@pytest.mark.network
96152
def test_install_report_vcs_and_wheel_cache(
97153
script: PipTestEnvironment, tmp_path: Path

0 commit comments

Comments
 (0)