Skip to content

Commit 453a5a7

Browse files
committed
Add test for combination of invalid link hash and good --hash
1 parent f5f0302 commit 453a5a7

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

tests/functional/test_install.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,13 +634,29 @@ def test_link_hash_pass_require_hashes(
634634
def test_bad_link_hash_install_failure(
635635
script: PipTestEnvironment, shared_data: TestData
636636
) -> None:
637-
"""Test that wrong hash in direct URL stop installation."""
637+
"""Test that wrong hash in direct URL stops installation."""
638638
url = path_to_url(str(shared_data.packages.joinpath("simple-1.0.tar.gz")))
639639
url = f"{url}#sha256=invalidhash"
640640
result = script.pip_install_local("--no-deps", url, expect_error=True)
641641
assert "THESE PACKAGES DO NOT MATCH THE HASHES" in result.stderr
642642

643643

644+
def test_bad_link_hash_good_user_hash_install_success(
645+
script: PipTestEnvironment, shared_data: TestData, tmp_path: Path
646+
) -> None:
647+
"""Test that wrong hash in direct URL ignored when good --hash provided.
648+
649+
This behaviour may be accidental?
650+
"""
651+
url = path_to_url(str(shared_data.packages.joinpath("simple-1.0.tar.gz")))
652+
url = f"{url}#sha256=invalidhash"
653+
digest = "393043e672415891885c9a2a0929b1af95fb866d6ca016b42d2e6ce53619b653"
654+
with requirements_file(
655+
f"simple @ {url} --hash sha256:{digest}", tmp_path
656+
) as reqs_file:
657+
script.pip_install_local("--no-deps", "--require-hashes", "-r", reqs_file)
658+
659+
644660
def test_link_hash_in_dep_fails_require_hashes(
645661
script: PipTestEnvironment, tmp_path: Path, shared_data: TestData
646662
) -> None:

0 commit comments

Comments
 (0)