1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00

add notes on hash mismatch testing

This commit is contained in:
Danny McClanahan 2023-08-12 10:46:22 -04:00
parent 20b54de4df
commit e27af2c3c9
No known key found for this signature in database
GPG key ID: CE8D0DA71DEFC1DF

View file

@ -106,9 +106,12 @@ def test_hash_mismatch(script: PipTestEnvironment, tmp_path: pathlib.Path) -> No
@mark.network @mark.network
def test_hash_mismatch_existing_download( def test_hash_mismatch_existing_download_for_metadata_only_wheel(
script: PipTestEnvironment, tmp_path: pathlib.Path script: PipTestEnvironment, tmp_path: pathlib.Path
) -> None: ) -> None:
"""Metadata-only wheels from PEP 658 or fast-deps check for hash matching in
a separate code path than when the wheel is downloaded all at once. Make sure we
still check for hash mismatches."""
reqs = tmp_path / "requirements.txt" reqs = tmp_path / "requirements.txt"
reqs.write_text("idna==2.10") reqs.write_text("idna==2.10")
dl_dir = tmp_path / "downloads" dl_dir = tmp_path / "downloads"
@ -117,6 +120,7 @@ def test_hash_mismatch_existing_download(
idna_wheel.write_text("asdf") idna_wheel.write_text("asdf")
result = script.pip( result = script.pip(
"download", "download",
# Ensure that we have a metadata-only dist for idna.
"--use-feature=fast-deps", "--use-feature=fast-deps",
"-r", "-r",
str(reqs), str(reqs),
@ -127,6 +131,7 @@ def test_hash_mismatch_existing_download(
assert re.search( assert re.search(
r"WARNING: Previously-downloaded file.*has bad hash", result.stderr r"WARNING: Previously-downloaded file.*has bad hash", result.stderr
) )
# This is the correct hash for idna==2.10.
assert ( assert (
hash_file(str(idna_wheel))[0].hexdigest() hash_file(str(idna_wheel))[0].hexdigest()
== "b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0" == "b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0"