Skip to content

Commit

Permalink
Merge pull request #1 from micheleAlberto/fixPrereleaseOption
Browse files Browse the repository at this point in the history
Add test and news file
  • Loading branch information
sauhard authored Oct 26, 2018
2 parents 5c2c407 + a9c03ec commit 4e036c5
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions news/5175.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix `PackageFinder.find_all_candidates` to enforce `allow_all_prereleases` option
38 changes: 38 additions & 0 deletions tests/unit/test_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,44 @@ def test_finder_installs_pre_releases(data):
link = finder.find_requirement(req, False)
assert link.url == "https://foo/bar-2.0b1.tar.gz"

def test_finder_does_not_candidate_pre_releases(data):
"""
Test PackageFinder finds pre-releases if asked to.
"""

req = install_req_from_line("bar", None)

# using a local index (that has pre & dev releases)
finder = PackageFinder(
[], [data.index_url("pre")],
allow_all_prereleases=False,
session=PipSession(),
)
for candidate in finder.find_all_candidates("bar"):
assert not candidate.version.is_prerelease

# using find-links
links = ["https://foo/bar-1.0.tar.gz", "https://foo/bar-2.0b1.tar.gz"]
finder = PackageFinder(
links, [],
allow_all_prereleases=True,
session=PipSession(),
)

with patch.object(finder, "_get_pages", lambda x, y: []):
for candidate in finder.find_all_candidates("bar"):
assert not candidate.version.is_prerelease

links.reverse()
finder = PackageFinder(
links, [],
allow_all_prereleases=True,
session=PipSession(),
)

with patch.object(finder, "_get_pages", lambda x, y: []):
for candidate in finder.find_all_candidates("bar"):
assert not candidate.version.is_prerelease

def test_finder_installs_dev_releases(data):
"""
Expand Down

0 comments on commit 4e036c5

Please sign in to comment.