Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix prerelease option #1

Merged
merged 3 commits into from
Oct 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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