|
1 | 1 | import json
|
| 2 | +import textwrap |
2 | 3 | from pathlib import Path
|
3 | 4 | from typing import Any, Dict
|
4 | 5 |
|
@@ -178,6 +179,97 @@ def test_install_report_vcs_editable(
|
178 | 179 | assert pip_test_package_report["download_info"]["dir_info"]["editable"] is True
|
179 | 180 |
|
180 | 181 |
|
| 182 | +@pytest.mark.network |
| 183 | +def test_install_report_local_path_with_extras( |
| 184 | + script: PipTestEnvironment, tmp_path: Path, shared_data: TestData |
| 185 | +) -> None: |
| 186 | + """Test report remote editable.""" |
| 187 | + project_path = tmp_path / "pkga" |
| 188 | + project_path.mkdir() |
| 189 | + project_path.joinpath("pyproject.toml").write_text( |
| 190 | + textwrap.dedent( |
| 191 | + """\ |
| 192 | + [project] |
| 193 | + name = "pkga" |
| 194 | + version = "1.0" |
| 195 | +
|
| 196 | + [project.optional-dependencies] |
| 197 | + test = ["simple"] |
| 198 | + """ |
| 199 | + ) |
| 200 | + ) |
| 201 | + report_path = tmp_path / "report.json" |
| 202 | + script.pip( |
| 203 | + "install", |
| 204 | + "--dry-run", |
| 205 | + "--no-build-isolation", |
| 206 | + "--no-index", |
| 207 | + "--find-links", |
| 208 | + str(shared_data.root / "packages/"), |
| 209 | + "--report", |
| 210 | + str(report_path), |
| 211 | + str(project_path) + "[test]", |
| 212 | + ) |
| 213 | + report = json.loads(report_path.read_text()) |
| 214 | + assert len(report["install"]) == 2 |
| 215 | + pkga_report = report["install"][0] |
| 216 | + assert pkga_report["metadata"]["name"] == "pkga" |
| 217 | + assert pkga_report["is_direct"] is True |
| 218 | + assert pkga_report["requested"] is True |
| 219 | + assert pkga_report["requested_extras"] == ["test"] |
| 220 | + simple_report = report["install"][1] |
| 221 | + assert simple_report["metadata"]["name"] == "simple" |
| 222 | + assert simple_report["is_direct"] is False |
| 223 | + assert simple_report["requested"] is False |
| 224 | + assert "requested_extras" not in simple_report |
| 225 | + |
| 226 | + |
| 227 | +@pytest.mark.network |
| 228 | +def test_install_report_editable_local_path_with_extras( |
| 229 | + script: PipTestEnvironment, tmp_path: Path, shared_data: TestData |
| 230 | +) -> None: |
| 231 | + """Test report remote editable.""" |
| 232 | + project_path = tmp_path / "pkga" |
| 233 | + project_path.mkdir() |
| 234 | + project_path.joinpath("pyproject.toml").write_text( |
| 235 | + textwrap.dedent( |
| 236 | + """\ |
| 237 | + [project] |
| 238 | + name = "pkga" |
| 239 | + version = "1.0" |
| 240 | +
|
| 241 | + [project.optional-dependencies] |
| 242 | + test = ["simple"] |
| 243 | + """ |
| 244 | + ) |
| 245 | + ) |
| 246 | + report_path = tmp_path / "report.json" |
| 247 | + script.pip( |
| 248 | + "install", |
| 249 | + "--dry-run", |
| 250 | + "--no-build-isolation", |
| 251 | + "--no-index", |
| 252 | + "--find-links", |
| 253 | + str(shared_data.root / "packages/"), |
| 254 | + "--report", |
| 255 | + str(report_path), |
| 256 | + "--editable", |
| 257 | + str(project_path) + "[test]", |
| 258 | + ) |
| 259 | + report = json.loads(report_path.read_text()) |
| 260 | + assert len(report["install"]) == 2 |
| 261 | + pkga_report = report["install"][0] |
| 262 | + assert pkga_report["metadata"]["name"] == "pkga" |
| 263 | + assert pkga_report["is_direct"] is True |
| 264 | + assert pkga_report["requested"] is True |
| 265 | + assert pkga_report["requested_extras"] == ["test"] |
| 266 | + simple_report = report["install"][1] |
| 267 | + assert simple_report["metadata"]["name"] == "simple" |
| 268 | + assert simple_report["is_direct"] is False |
| 269 | + assert simple_report["requested"] is False |
| 270 | + assert "requested_extras" not in simple_report |
| 271 | + |
| 272 | + |
181 | 273 | def test_install_report_to_stdout(
|
182 | 274 | script: PipTestEnvironment, shared_data: TestData
|
183 | 275 | ) -> None:
|
|
0 commit comments