kopie van https://github.com/pypa/pip
Eliminate len() usage in tests
This commit is contained in:
bovenliggende
17d0086ea2
commit
761433cee8
|
@ -83,13 +83,12 @@ class FoundCandidates(collections_abc.Sequence):
|
|||
candidates = _insert_installed(self._installed, self._get_others())
|
||||
return _deduplicated_by_version(candidates)
|
||||
|
||||
@lru_cache(maxsize=1)
|
||||
def __len__(self):
|
||||
# type: () -> int
|
||||
# Implement to satisfy the ABC check and used in tests. This is not
|
||||
# needed by the resolver, and should not be used by the provider either
|
||||
# (for performance reasons).
|
||||
return sum(1 for _ in self)
|
||||
# Implemented to satisfy the ABC check. This is not needed by the
|
||||
# resolver, and should not be used by the provider either (for
|
||||
# performance reasons).
|
||||
raise NotImplementedError("don't do this")
|
||||
|
||||
@lru_cache(maxsize=1)
|
||||
def __bool__(self):
|
||||
|
|
|
@ -61,7 +61,7 @@ def test_new_resolver_correct_number_of_matches(test_cases, factory):
|
|||
matches = factory.find_candidates(
|
||||
[req], Constraint.empty(), prefers_installed=False,
|
||||
)
|
||||
assert len(list(matches)) == match_count
|
||||
assert sum(1 for _ in matches) == match_count
|
||||
|
||||
|
||||
def test_new_resolver_candidates_match_requirement(test_cases, factory):
|
||||
|
|
Laden…
Verwijs in nieuw issue