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 PackageFinder to respect allow_all_prereleases #5927

Closed
wants to merge 7 commits into from
Closed
Changes from 1 commit
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
Next Next commit
test that PackageFinder filters out prereleases from candidates
micheleAlberto committed Oct 26, 2018
commit 7f057dc6fbbc3012288014f6f5123054263ab049
38 changes: 38 additions & 0 deletions tests/unit/test_finder.py
Original file line number Diff line number Diff line change
@@ -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 link in finder.find_all_candidates("bar"):
assert not link.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 link in finder.find_all_candidates("bar"):
assert not link.version.is_prerelease

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

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

def test_finder_installs_dev_releases(data):
"""