Skip to content

Commit af735bc

Browse files
committed
fail on inconsistent lock file
1 parent db7edd9 commit af735bc

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

src/poetry_plugin_export/command.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,12 @@ def handle(self) -> int:
104104

105105
if not locker.is_fresh():
106106
self.line_error(
107-
"<warning>"
108-
"Warning: poetry.lock is not consistent with pyproject.toml. "
109-
"You may be getting improper dependencies. "
110-
"Run `poetry lock [--no-update]` to fix it."
111-
"</warning>"
107+
"<error>"
108+
"pyproject.toml changed significantly since poetry.lock was last"
109+
" generated. Run `poetry lock` to fix the lock file."
110+
"</error>"
112111
)
112+
return 1
113113

114114
if self.option("extras") and self.option("all-extras"):
115115
self.line_error(

tests/command/test_command_export.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from cleo.testers.command_tester import CommandTester
2222
from poetry.poetry import Poetry
2323
from poetry.repositories import Repository
24+
from pytest_mock import MockerFixture
2425

2526
from tests.types import CommandTesterFactory
2627
from tests.types import ProjectFactory
@@ -134,6 +135,18 @@ def test_export_fails_on_invalid_format(tester: CommandTester, do_lock: None) ->
134135
tester.execute("--format invalid")
135136

136137

138+
def test_export_fails_if_lockfile_is_not_fresh(
139+
tester: CommandTester,
140+
poetry: Poetry,
141+
tmp_path: Path,
142+
do_lock: None,
143+
mocker: MockerFixture,
144+
) -> None:
145+
mocker.patch.object(poetry.locker, "is_fresh", return_value=False)
146+
assert tester.execute() == 1
147+
assert "pyproject.toml changed significantly" in tester.io.fetch_error()
148+
149+
137150
def test_export_prints_to_stdout_by_default(
138151
tester: CommandTester, do_lock: None
139152
) -> None:

0 commit comments

Comments
 (0)