From 649a40a1c9708ad33b40f4a788f23190764b1cb1 Mon Sep 17 00:00:00 2001 From: John Sirois Date: Thu, 24 Oct 2024 21:10:14 -0700 Subject: [PATCH] Add a test of pure lock deletes for complex deps. (#2576) I claimed there was already one of these in #2569 but I was wrong because the existing complex case test include an update; so is not a pure delete. Add a new test of the pure delete case where the deleted node's graph is partially retained. --- .../test_lock_update_issues_2332_2334.py | 36 +++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/tests/integration/cli/commands/test_lock_update_issues_2332_2334.py b/tests/integration/cli/commands/test_lock_update_issues_2332_2334.py index e5e31a8b0..c8b54284a 100644 --- a/tests/integration/cli/commands/test_lock_update_issues_2332_2334.py +++ b/tests/integration/cli/commands/test_lock_update_issues_2332_2334.py @@ -80,13 +80,13 @@ def populate_find_links_repo_initial( # N.B.: Since we are setting up a find links repo for offline lock resolves, we grab one # distribution online to allow the current Pip version to bootstrap itself if needed. result = resolver.resolve_requirements( - ["ansicolors==1.1.8"], result_type=InstallableType.WHEEL_FILE + ["ansicolors==1.1.8", "cowsay==6.0.0"], result_type=InstallableType.WHEEL_FILE ) for resolved_distribution in result.distributions: find_links_repo.host(resolved_distribution.distribution.location) find_links_repo.make_wheel("proj-c", "1") - find_links_repo.make_wheel("proj-b", "1", requirements=["proj-a", "proj-c"]) + find_links_repo.make_wheel("proj-b", "1", requirements=["proj-a", "proj-c", "cowsay"]) find_links_repo.make_wheel("proj-a", "1", requirements=["proj-c", "ansicolors"]) find_links_repo.make_wheel("proj-a", "1.1", requirements=["proj-c", "ansicolors"]) @@ -277,6 +277,7 @@ def test_lock_update_conflict( The following lock update constraints could not all be satisfied: ansicolors==1.1.8 + cowsay==6 proj-a==1.1 proj-b>=2 proj-c==1 @@ -377,6 +378,7 @@ def test_lock_update_delete_nominal( dedent( """\ Updates for lock generated by universal: + Deleted cowsay 6 Deleted proj-b 1 Updates to lock input requirements: Deleted 'proj-b==1.*' @@ -450,6 +452,7 @@ def test_lock_update_mixed( dedent( """\ Updates for lock generated by universal: + Deleted cowsay 6 Deleted proj-b 1 Deleted proj-c 1 Updated proj-a from 1.1 to 2 @@ -462,3 +465,32 @@ def test_lock_update_mixed( lockfile = json_codec.load(lock, path_mappings) locked_requirements = locked_requirement_pins(lockfile) assert {pin("proj-a", "2"), pin("ansicolors", "1.1.8")} == locked_requirements + + +def test_lock_delete_complex( + run_lock_update, # type: RunLockUpdate + lock, # type: str + path_mappings, # type: PathMappings +): + # type: (...) -> None + + run_lock_update("-d", "proj-b").assert_success( + expected_error_re=re_exact( + dedent( + """\ + Updates for lock generated by universal: + Deleted cowsay 6 + Deleted proj-b 1 + Updates to lock input requirements: + Deleted 'proj-b==1.*' + """ + ) + ) + ) + lockfile = json_codec.load(lock, path_mappings) + locked_requirements = locked_requirement_pins(lockfile) + assert { + pin("proj-a", "1.1"), + pin("proj-c", "1"), + pin("ansicolors", "1.1.8"), + } == locked_requirements