Skip to content

Commit

Permalink
fix: throw error on pinned without latest
Browse files Browse the repository at this point in the history
  • Loading branch information
KotlinIsland authored and MousaZeidBaker committed Feb 10, 2023
1 parent 692f7c5 commit 95aaeac
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/poetry_plugin_up/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ class UpCommand(InstallerCommand):
option(
long_name="pinned",
short_name=None,
description="Included pinned dependencies when updating to latest.",
description=(
"Include pinned (exact) dependencies when updating to latest."
),
),
option(
long_name="no-install",
Expand All @@ -58,6 +60,10 @@ def handle(self) -> int:
no_install = self.option("no-install")
dry_run = self.option("dry-run")

if pinned and not latest:
self.line_error("'--pinned' specified without '--latest'")
raise Exception

selector = VersionSelector(self.poetry.pool)
pyproject_content = self.poetry.file.read()
original_pyproject_content = self.poetry.file.read()
Expand Down
4 changes: 4 additions & 0 deletions tests/e2e/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,7 @@ def test_command_reverts_pyproject_on_error(
assert app_tester.execute("up") == 1
assert PyProjectTOML(tmp_pyproject_path).file.read() == expected
command_call.assert_called_once_with(name="update")


def test_pinned_without_latest_fails(app_tester: ApplicationTester) -> None:
assert app_tester.execute("up --pinned") == 1

0 comments on commit 95aaeac

Please sign in to comment.