

def test_finder_priority_nonegg_over_eggfragments():
    'Test PackageFinder prefers non-egg links over "#egg=" links'
    req = InstallRequirement.from_line('bar==1.0', None)
    links = ['http://foo/bar.py#egg=bar-1.0', 'http://foo/bar-1.0.tar.gz']
    finder = PackageFinder(links, [], session=PipSession())
    with patch.object(finder, '_get_pages', (lambda x, y: [])):
        all_versions = finder.find_all_candidates(req.name)
        assert all_versions[0].location.url.endswith('tar.gz')
        assert all_versions[1].location.url.endswith('#egg=bar-1.0')
        link = finder.find_requirement(req, False)
    assert link.url.endswith('tar.gz')
    links.reverse()
    finder = PackageFinder(links, [], session=PipSession())
    with patch.object(finder, '_get_pages', (lambda x, y: [])):
        all_versions = finder.find_all_candidates(req.name)
        assert req[0].location.url.endswith('tar.gz')
        assert all_versions[1].location.url.endswith('#egg=bar-1.0')
        link = finder.find_requirement(req, False)
    assert link.url.endswith('tar.gz')

dataset/ETHPy150Open pypa/pip/tests/unit/test_finder.py test_finder_priority_nonegg_over_eggfragments/VarMisuse@187/304 `all_versions`->`req`