Commit 1196923d by Artem Rys Committed by GitHub

Add output for poetry lock --check (#5081)

* Add output for poetry lock --check

* Rephrase messages

* Add punctuation mark at the end of the message

* Update wording for installer and export

* Put warning back for installer and export

* Finalize warning messages

* Improve fix messages
parent 31657e7e
...@@ -59,10 +59,9 @@ class ExportCommand(Command): ...@@ -59,10 +59,9 @@ class ExportCommand(Command):
if not locker.is_fresh(): if not locker.is_fresh():
self.line_error( self.line_error(
"<warning>" "<warning>"
"Warning: The lock file is not up to date with " "Warning: poetry.lock is not consistent with pyproject.toml. "
"the latest changes in pyproject.toml. " "You may be getting improper dependencies. "
"You may be getting outdated dependencies. " "Run `poetry lock [--no-update]` to fix it."
"Run update to update them."
"</warning>" "</warning>"
) )
......
...@@ -37,11 +37,16 @@ file. ...@@ -37,11 +37,16 @@ file.
) )
if self.option("check"): if self.option("check"):
return ( if self.poetry.locker.is_locked() and self.poetry.locker.is_fresh():
0 self.line("poetry.lock is consistent with pyproject.toml.")
if self.poetry.locker.is_locked() and self.poetry.locker.is_fresh() return 0
else 1 self.line(
"<error>"
"Error: poetry.lock is not consistent with pyproject.toml. "
"Run `poetry lock [--no-update]` to fix it."
"</error>"
) )
return 1
self._installer.lock(update=not self.option("no-update")) self._installer.lock(update=not self.option("no-update"))
......
...@@ -258,10 +258,9 @@ class Installer: ...@@ -258,10 +258,9 @@ class Installer:
if not self._locker.is_fresh(): if not self._locker.is_fresh():
self._io.write_line( self._io.write_line(
"<warning>" "<warning>"
"Warning: The lock file is not up to date with " "Warning: poetry.lock is not consistent with pyproject.toml. "
"the latest changes in pyproject.toml. " "You may be getting improper dependencies. "
"You may be getting outdated dependencies. " "Run `poetry lock [--no-update]` to fix it."
"Run update to update them."
"</warning>" "</warning>"
) )
......
...@@ -81,6 +81,12 @@ def test_lock_check_outdated( ...@@ -81,6 +81,12 @@ def test_lock_check_outdated(
tester = command_tester_factory("lock", poetry=poetry_with_outdated_lockfile) tester = command_tester_factory("lock", poetry=poetry_with_outdated_lockfile)
status_code = tester.execute("--check") status_code = tester.execute("--check")
expected = (
"Error: poetry.lock is not consistent with pyproject.toml. "
"Run `poetry lock [--no-update]` to fix it.\n"
)
assert tester.io.fetch_output() == expected
# exit with an error # exit with an error
assert status_code == 1 assert status_code == 1
...@@ -101,6 +107,8 @@ def test_lock_check_up_to_date( ...@@ -101,6 +107,8 @@ def test_lock_check_up_to_date(
tester = command_tester_factory("lock", poetry=poetry_with_up_to_date_lockfile) tester = command_tester_factory("lock", poetry=poetry_with_up_to_date_lockfile)
status_code = tester.execute("--check") status_code = tester.execute("--check")
expected = "poetry.lock is consistent with pyproject.toml.\n"
assert tester.io.fetch_output() == expected
# exit with an error # exit with an error
assert status_code == 0 assert status_code == 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment