Skip to content

Commit

Permalink
Do not normalise iter_provided_extras from pkg_resources
Browse files Browse the repository at this point in the history
This is explicitly checked for in the test suite and it isn't strictly
necessary to ensure the correct behaviour. This does expose that the
test mock objects are incomplete so those get a missing `extra`
attribute added.
  • Loading branch information
pradyunsg committed Oct 6, 2023
1 parent 62520f9 commit d8bb25d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/pip/_internal/metadata/pkg_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def iter_dependencies(self, extras: Collection[str] = ()) -> Iterable[Requiremen
return self._dist.requires(extras)

def iter_provided_extras(self) -> Iterable[str]:
return self._extra_mapping.keys()
return self._dist.extras

def is_extra_provided(self, extra: str) -> bool:
return canonicalize_name(extra) in self._extra_mapping
Expand Down
12 changes: 6 additions & 6 deletions tests/unit/metadata/test_metadata_pkg_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ def require(self, name: str) -> None:

workingset = _MockWorkingSet(
(
mock.Mock(test_name="global", project_name="global"),
mock.Mock(test_name="editable", project_name="editable"),
mock.Mock(test_name="normal", project_name="normal"),
mock.Mock(test_name="user", project_name="user"),
mock.Mock(test_name="global", project_name="global", extras=[]),
mock.Mock(test_name="editable", project_name="editable", extras=[]),
mock.Mock(test_name="normal", project_name="normal", extras=[]),
mock.Mock(test_name="user", project_name="user", extras=[]),
)
)

workingset_stdlib = _MockWorkingSet(
(
mock.Mock(test_name="normal", project_name="argparse"),
mock.Mock(test_name="normal", project_name="wsgiref"),
mock.Mock(test_name="normal", project_name="argparse", extras=[]),
mock.Mock(test_name="normal", project_name="wsgiref", extras=[]),
)
)

Expand Down

0 comments on commit d8bb25d

Please sign in to comment.