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):
if not locker.is_fresh():
self.line_error(
"<warning>"
"Warning: The lock file is not up to date with "
"the latest changes in pyproject.toml. "
"You may be getting outdated dependencies. "
"Run update to update them."
"Warning: poetry.lock is not consistent with pyproject.toml. "
"You may be getting improper dependencies. "
"Run `poetry lock [--no-update]` to fix it."
"</warning>"
)
......
......@@ -37,11 +37,16 @@ file.
)
if self.option("check"):
return (
0
if self.poetry.locker.is_locked() and self.poetry.locker.is_fresh()
else 1
if self.poetry.locker.is_locked() and self.poetry.locker.is_fresh():
self.line("poetry.lock is consistent with pyproject.toml.")
return 0
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"))
......
......@@ -258,10 +258,9 @@ class Installer:
if not self._locker.is_fresh():
self._io.write_line(
"<warning>"
"Warning: The lock file is not up to date with "
"the latest changes in pyproject.toml. "
"You may be getting outdated dependencies. "
"Run update to update them."
"Warning: poetry.lock is not consistent with pyproject.toml. "
"You may be getting improper dependencies. "
"Run `poetry lock [--no-update]` to fix it."
"</warning>"
)
......
......@@ -81,6 +81,12 @@ def test_lock_check_outdated(
tester = command_tester_factory("lock", poetry=poetry_with_outdated_lockfile)
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
assert status_code == 1
......@@ -101,6 +107,8 @@ def test_lock_check_up_to_date(
tester = command_tester_factory("lock", poetry=poetry_with_up_to_date_lockfile)
status_code = tester.execute("--check")
expected = "poetry.lock is consistent with pyproject.toml.\n"
assert tester.io.fetch_output() == expected
# exit with an error
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