Commit e403ff46 by Branch Vincent Committed by GitHub

fix(show): handle missing lockfile (#5242)

parent da9680b0
......@@ -129,6 +129,13 @@ lists all packages available."""
if self.option("default"):
only_groups.append("default")
if not self.poetry.locker.is_locked():
self.line_error(
"<error>Error: poetry.lock not found. Run `poetry lock` to create"
" it.</error>"
)
return 1
locked_repo = self.poetry.locker.locked_repository(True)
if only_groups:
......
......@@ -1587,3 +1587,13 @@ required by
""".splitlines()
actual = [line.rstrip() for line in tester.io.fetch_output().splitlines()]
assert actual == expected
def test_show_errors_without_lock_file(tester: "CommandTester", poetry: "Poetry"):
assert not poetry.locker.lock.exists()
tester.execute()
expected = "Error: poetry.lock not found. Run `poetry lock` to create it.\n"
assert tester.io.fetch_error() == expected
assert tester.status_code == 1
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