Skip to content

Commit

Permalink
Merge pull request #822 from atugushev/respect-infile-pre-option
Browse files Browse the repository at this point in the history
Respect --pre option in requirements.in file
  • Loading branch information
atugushev authored May 24, 2019
2 parents 0eeb7de + 70c8fc4 commit 4438d98
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion piptools/scripts/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def cli(
resolver = Resolver(
constraints,
repository,
prereleases=pre,
prereleases=repository.finder.allow_all_prereleases or pre,
clear_caches=rebuild,
allow_unsafe=allow_unsafe,
)
Expand Down
16 changes: 11 additions & 5 deletions tests/test_cli_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,22 +649,28 @@ def test_build_isolation_option(MockPyPIRepository, runner, option, expected):


@pytest.mark.parametrize(
"pre_option, expected_package",
"cli_option, infile_option, expected_package",
[
# no --pre pip-compile should resolve to the last stable version
([], "small-fake-a==0.2"),
(False, False, "small-fake-a==0.2"),
# pip-compile --pre should resolve to the last pre-released version
(["-p"], "small-fake-a==0.3b1"),
(True, False, "small-fake-a==0.3b1"),
(False, True, "small-fake-a==0.3b1"),
(True, True, "small-fake-a==0.3b1"),
],
)
def test_pre_option(runner, pre_option, expected_package):
def test_pre_option(runner, cli_option, infile_option, expected_package):
"""
Tests pip-compile respects --pre option.
"""
with open("requirements.in", "w") as req_in:
if infile_option:
req_in.write("--pre\n")
req_in.write("small-fake-a\n")

out = runner.invoke(cli, ["-n", "-f", MINIMAL_WHEELS_PATH] + pre_option)
out = runner.invoke(
cli, ["-n", "-f", MINIMAL_WHEELS_PATH] + (["-p"] if cli_option else [])
)

assert out.exit_code == 0, out.output
assert expected_package in out.output.splitlines(), out.output

0 comments on commit 4438d98

Please sign in to comment.