def test_finder_only_installs_stable_releases(data):
 req = InstallRequirement.from_line('bar', None)
 finder = PackageFinder([], [data.index_url('pre')], session=PipSession())
 link = finder.find_requirement(req, False)
 assert link.url.endswith('bar-1.0.tar.gz'), link.url
 links = ['https://foo/bar-1.0.tar.gz', 'https://foo/bar-2.0b1.tar.gz']
 finder = PackageFinder(links, [], session=PipSession())
 with patch.object(finder, '_get_pages', (lambda x, y: [])):
  link = finder.find_requirement(req, False)
  assert (link.url == 'https://foo/bar-1.0.tar.gz')
 links.reverse()
 finder = PackageFinder(links, [], session=PipSession())
 with patch.object(finder, '_get_pages', (lambda x, y: [])):
  link = finder.find_requirement(req, False)
  assert (link.url == 'https://foo/bar-1.0.tar.gz')

def test_finder_only_installs_stable_releases ( data ) : req = InstallRequirement . from_line ( 'bar' , None ) finder = PackageFinder ( [ ] , [ data . index_url ( 'pre' ) ] , session = PipSession ( ) ) link = finder . find_requirement ( req , False ) assert link . url . endswith ( 'bar-1.0.tar.gz' ) , link . url links = [ 'https://foo/bar-1.0.tar.gz' , 'https://foo/bar-2.0b1.tar.gz' ] finder = PackageFinder ( links , [ ] , session = PipSession ( ) ) with patch . object ( finder , '_get_pages' , ( lambda x , y : [ ] ) ) : link = finder . find_requirement ( req , False ) assert ( link . url == 'https://foo/bar-1.0.tar.gz' ) links . reverse ( ) finder = PackageFinder ( links , [ ] , session = PipSession ( ) ) with patch . object ( finder , '_get_pages' , ( lambda x , y : [ ] ) ) : link = finder . find_requirement ( req , False ) assert ( link . url == 'https://foo/bar-1.0.tar.gz' )
test packagefinder only accepts stable versioned releases by default .