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

Fail command install if cannot be installed #9333

Merged
merged 1 commit into from
Sep 15, 2024
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
7 changes: 3 additions & 4 deletions src/poetry/console/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,10 @@ def handle(self) -> int:
" use <c1>--no-root</c1>.\n"
"If you want to use Poetry only for dependency management"
" but not for packaging, you can disable package mode by setting"
" <c1>package-mode = false</> in your pyproject.toml file.\n"
"In a future version of Poetry this warning will become an error!",
style="warning",
" <c1>package-mode = false</> in your pyproject.toml file.\n",
style="error",
)
return 0
return 1

if overwrite:
self.overwrite(log_install.format(tag="success"))
Expand Down
12 changes: 8 additions & 4 deletions tests/console/commands/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def test_group_options_are_passed_to_the_installer(

status_code = tester.execute(options)

if options == "--no-root --only-root":
if options == "--no-root --only-root" or with_root:
assert status_code == 1
return
else:
Expand Down Expand Up @@ -322,7 +322,7 @@ def test_invalid_groups_with_without_only(

if not should_raise:
tester.execute(cmd_args)
assert tester.status_code == 0
assert tester.status_code == 1
else:
with pytest.raises(GroupNotFound, match=r"^Group\(s\) not found:") as e:
tester.execute(cmd_args)
Expand All @@ -345,7 +345,7 @@ def test_remove_untracked_outputs_deprecation_warning(

tester.execute("--remove-untracked")

assert tester.status_code == 0
assert tester.status_code == 1
assert (
"The `--remove-untracked` option is deprecated, use the `--sync` option"
" instead.\n" in tester.io.fetch_error()
Expand Down Expand Up @@ -440,7 +440,11 @@ def test_install_warning_corrupt_root(
tester = command_tester_factory("install", poetry=poetry)
tester.execute("" if with_root else "--no-root")

assert tester.status_code == 0
if error and with_root:
assert tester.status_code == 1
else:
assert tester.status_code == 0

if with_root and error:
assert "The current project could not be installed: " in tester.io.fetch_error()
else:
Expand Down
Loading