|
6 | 6 | create_basic_wheel_for_package, |
7 | 7 | create_test_package_with_setup, |
8 | 8 | ) |
| 9 | +from tests.lib.wheel import make_wheel |
9 | 10 |
|
10 | 11 |
|
11 | 12 | def test_new_resolver_conflict_requirements_file( |
@@ -134,3 +135,61 @@ def test_new_resolver_checks_requires_python_before_dependencies( |
134 | 135 | # Setuptools produces wheels with normalized names. |
135 | 136 | assert "pkg_dep" not in result.stderr, str(result) |
136 | 137 | assert "pkg_dep" not in result.stdout, str(result) |
| 138 | + |
| 139 | + |
| 140 | +def test_new_resolver_no_versions_available_hint(script: PipTestEnvironment) -> None: |
| 141 | + """ |
| 142 | + Test hint that no package candidate is available at all, |
| 143 | + when ResolutionImpossible occurs. |
| 144 | + """ |
| 145 | + wheel_house = script.scratch_path.joinpath("wheelhouse") |
| 146 | + wheel_house.mkdir() |
| 147 | + |
| 148 | + incompatible_dep_wheel = make_wheel( |
| 149 | + name="incompatible-dep", |
| 150 | + version="1.0.0", |
| 151 | + wheel_metadata_updates={"Tag": ["py3-none-fakeplat"]}, |
| 152 | + ) |
| 153 | + incompatible_dep_wheel.save_to( |
| 154 | + wheel_house.joinpath("incompatible_dep-1.0.0-py3-none-fakeplat.whl") |
| 155 | + ) |
| 156 | + |
| 157 | + # Create multiple versions of a package that depend on the incompatible dependency |
| 158 | + requesting_pkg_v1 = make_wheel( |
| 159 | + name="requesting-pkg", |
| 160 | + version="1.0.0", |
| 161 | + metadata_updates={"Requires-Dist": ["incompatible-dep==1.0.0"]}, |
| 162 | + ) |
| 163 | + requesting_pkg_v1.save_to( |
| 164 | + wheel_house.joinpath("requesting_pkg-1.0.0-py2.py3-none-any.whl") |
| 165 | + ) |
| 166 | + |
| 167 | + requesting_pkg_v2 = make_wheel( |
| 168 | + name="requesting-pkg", |
| 169 | + version="2.0.0", |
| 170 | + metadata_updates={"Requires-Dist": ["incompatible-dep==1.0.0"]}, |
| 171 | + ) |
| 172 | + requesting_pkg_v2.save_to( |
| 173 | + wheel_house.joinpath("requesting_pkg-2.0.0-py2.py3-none-any.whl") |
| 174 | + ) |
| 175 | + |
| 176 | + # Attempt to install the requesting package |
| 177 | + result = script.pip( |
| 178 | + "install", |
| 179 | + "--no-cache-dir", |
| 180 | + "--no-index", |
| 181 | + "--find-links", |
| 182 | + str(wheel_house), |
| 183 | + "requesting-pkg", |
| 184 | + expect_error=True, |
| 185 | + ) |
| 186 | + |
| 187 | + # Check that ResolutionImpossible error occurred |
| 188 | + assert "ResolutionImpossible" in result.stderr, str(result) |
| 189 | + |
| 190 | + # Check that the new hint message is present |
| 191 | + assert ( |
| 192 | + "Additionally, some packages in these conflicts have no " |
| 193 | + "matching distributions available for your environment:\n" |
| 194 | + " incompatible-dep\n" in result.stdout |
| 195 | + ), str(result) |
0 commit comments