Skip to content

Commit 5594079

Browse files
eamanuradoering
authored andcommitted
Fail command install if cannot be installed
An error code is returned if the installation command fails. Also the style is changed from warning to error. Tests was updated.
1 parent 119a3d7 commit 5594079

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/poetry/console/commands/install.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,10 @@ def handle(self) -> int:
200200
" use <c1>--no-root</c1>.\n"
201201
"If you want to use Poetry only for dependency management"
202202
" but not for packaging, you can disable package mode by setting"
203-
" <c1>package-mode = false</> in your pyproject.toml file.\n"
204-
"In a future version of Poetry this warning will become an error!",
205-
style="warning",
203+
" <c1>package-mode = false</> in your pyproject.toml file.\n",
204+
style="error",
206205
)
207-
return 0
206+
return 1
208207

209208
if overwrite:
210209
self.overwrite(log_install.format(tag="success"))

tests/console/commands/test_install.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def test_group_options_are_passed_to_the_installer(
136136

137137
status_code = tester.execute(options)
138138

139-
if options == "--no-root --only-root":
139+
if options == "--no-root --only-root" or with_root:
140140
assert status_code == 1
141141
return
142142
else:
@@ -322,7 +322,7 @@ def test_invalid_groups_with_without_only(
322322

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

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

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

443-
assert tester.status_code == 0
443+
if error and with_root:
444+
assert tester.status_code == 1
445+
else:
446+
assert tester.status_code == 0
447+
444448
if with_root and error:
445449
assert "The current project could not be installed: " in tester.io.fetch_error()
446450
else:

0 commit comments

Comments
 (0)