|
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,51 @@ 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 | + |
181 | 227 | def test_install_report_to_stdout(
|
182 | 228 | script: PipTestEnvironment, shared_data: TestData
|
183 | 229 | ) -> None:
|
|
0 commit comments