Skip to content

Commit 761433c

Browse files
committed
Eliminate len() usage in tests
1 parent 17d0086 commit 761433c

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/pip/_internal/resolution/resolvelib/found_candidates.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,12 @@ def __iter__(self):
8383
candidates = _insert_installed(self._installed, self._get_others())
8484
return _deduplicated_by_version(candidates)
8585

86-
@lru_cache(maxsize=1)
8786
def __len__(self):
8887
# type: () -> int
89-
# Implement to satisfy the ABC check and used in tests. This is not
90-
# needed by the resolver, and should not be used by the provider either
91-
# (for performance reasons).
92-
return sum(1 for _ in self)
88+
# Implemented to satisfy the ABC check. This is not needed by the
89+
# resolver, and should not be used by the provider either (for
90+
# performance reasons).
91+
raise NotImplementedError("don't do this")
9392

9493
@lru_cache(maxsize=1)
9594
def __bool__(self):

tests/unit/resolution_resolvelib/test_requirement.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def test_new_resolver_correct_number_of_matches(test_cases, factory):
6161
matches = factory.find_candidates(
6262
[req], Constraint.empty(), prefers_installed=False,
6363
)
64-
assert len(list(matches)) == match_count
64+
assert sum(1 for _ in matches) == match_count
6565

6666

6767
def test_new_resolver_candidates_match_requirement(test_cases, factory):

0 commit comments

Comments
 (0)