Skip to content

Commit

Permalink
Add a test of pure lock deletes for complex deps. (#2576)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jsirois authored Oct 25, 2024
1 parent a84476a commit 649a40a
Showing 1 changed file with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"])

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.*'
Expand Down Expand Up @@ -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
Expand All @@ -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

0 comments on commit 649a40a

Please sign in to comment.