From c4d9f563dd827906732da466131425b397f68897 Mon Sep 17 00:00:00 2001 From: Tzu-ping Chung Date: Sat, 23 Oct 2021 23:49:24 +0800 Subject: [PATCH] Add failing test for extra-already-installed case --- tests/functional/test_new_resolver.py | 33 +++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/functional/test_new_resolver.py b/tests/functional/test_new_resolver.py index a1e4c9b28d3..abff7d4f056 100644 --- a/tests/functional/test_new_resolver.py +++ b/tests/functional/test_new_resolver.py @@ -2180,3 +2180,36 @@ def test_new_resolver_dont_backtrack_on_extra_if_base_constrained(script): ) assert "pkg-2.0" not in result.stdout, "Should not try 2.0 due to constraint" script.assert_installed(pkg="1.0", dep="1.0") + + +def test_new_resolver_respect_user_requested_if_extra_is_installed(script): + create_basic_wheel_for_package(script, "pkg1", "1.0") + create_basic_wheel_for_package(script, "pkg2", "1.0", extras={"ext": ["pkg1"]}) + create_basic_wheel_for_package(script, "pkg2", "2.0", extras={"ext": ["pkg1"]}) + create_basic_wheel_for_package(script, "pkg3", "1.0", depends=["pkg2[ext]"]) + + # Install pkg3 with an older pkg2. + script.pip( + "install", + "--no-cache-dir", + "--no-index", + "--find-links", + script.scratch_path, + "pkg3", + "pkg2==1.0", + ) + script.assert_installed(pkg3="1.0", pkg2="1.0", pkg1="1.0") + + # Now upgrade both pkg3 and pkg2. pkg2 should be upgraded although pkg2[ext] + # is not requested by the user. + script.pip( + "install", + "--no-cache-dir", + "--no-index", + "--find-links", + script.scratch_path, + "--upgrade", + "pkg3", + "pkg2", + ) + script.assert_installed(pkg3="1.0", pkg2="2.0", pkg1="1.0")