Skip to content

Commit d32a62b

Browse files
committed
Use canonical names as keys in installation report
1 parent 2c84a1c commit d32a62b

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/pip/_internal/models/installation_report.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import Any, Dict, Sequence
22

33
from pip._vendor.packaging.markers import default_environment
4+
from pip._vendor.packaging.utils import canonicalize_name
45

56
from pip._internal.req.req_install import InstallRequirement
67

@@ -38,7 +39,9 @@ def _install_req_to_dict(cls, ireq: InstallRequirement) -> Dict[str, Any]:
3839
def to_dict(self) -> Dict[str, Any]:
3940
return {
4041
"install": {
41-
ireq.get_dist().metadata["Name"]: self._install_req_to_dict(ireq)
42+
canonicalize_name(ireq.metadata["Name"]): self._install_req_to_dict(
43+
ireq
44+
)
4245
for ireq in self._install_requirements
4346
},
4447
"environment": default_environment(),

tests/functional/test_install_report.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ def test_install_report_index(script: PipTestEnvironment, tmp_path: Path) -> Non
7474
)
7575
report = json.loads(report_path.read_text())
7676
assert len(report["install"]) == 2
77-
assert report["install"]["Paste"]["requested"] is True
77+
assert report["install"]["paste"]["requested"] is True
7878
assert report["install"]["python-openid"]["requested"] is False
79-
paste_report = report["install"]["Paste"]
79+
paste_report = report["install"]["paste"]
8080
assert paste_report["download_info"]["url"].startswith(
8181
"https://files.pythonhosted.org/"
8282
)

0 commit comments

Comments
 (0)