def test_no_candidate_found_no_versions(): ireq = install_req_from_line('some-package==12.3.4') tried = [] no_candidate_found = NoCandidateFound(ireq, tried, get_finder()) assert '{}'.format(no_candidate_found) == ( "Could not find a version that matches some-package==12.3.4\n" "No versions found\n" "Was pypi.localhost reachable?")
def test_no_candidate_found_no_versions(): ireq = InstallRequirement.from_line('some-package==12.3.4') tried = [] no_candidate_found = NoCandidateFound(ireq, tried, ['pypi.localhost']) assert '{}'.format(no_candidate_found) == ( "Could not find a version that matches some-package==12.3.4\n" "Tried: (no version found at all)\n" "Was pypi.localhost reachable?")
def test_no_candidate_found_with_versions(): ireq = install_req_from_line('some-package==12.3.4') tried = [ InstallationCandidate('some-package', ver, None) for ver in ['1.2.3', '12.3.0', '12.3.5']] no_candidate_found = NoCandidateFound(ireq, tried, get_finder()) assert '{}'.format(no_candidate_found) == ( "Could not find a version that matches some-package==12.3.4\n" "Tried: 1.2.3, 12.3.0, 12.3.5\n" "There are incompatible versions in the resolved dependencies.")
def find_best_match(self, ireq, prereleases=False): if ireq.editable: return ireq versions = list(ireq.specifier.filter(self.index[key_from_ireq(ireq)], prereleases=prereleases)) if not versions: raise NoCandidateFound(ireq, self.index[key_from_ireq(ireq)], ['https://fake.url.foo']) best_version = max(versions, key=Version) return make_install_requirement( name_from_req(ireq).lower(), best_version, ireq.extras, constraint=ireq.constraint)