Skip to content

Commit

Permalink
fix: Correct error message when pypi-token.pypi has incorrect number …
Browse files Browse the repository at this point in the history
…of arguments. (#8502)
  • Loading branch information
radoshi authored Oct 6, 2023
1 parent ebb91e2 commit 30da950
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/poetry/console/commands/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ def handle(self) -> int:

# show the value if no value is provided
if not self.argument("value") and not self.option("unset"):
if setting_key.split(".")[0] in self.LIST_PROHIBITED_SETTINGS:
raise ValueError(f"Expected a value for {setting_key} setting.")

m = re.match(r"^repos?(?:itories)?(?:\.(.+))?", self.argument("key"))
value: str | dict[str, Any]
if m:
Expand Down
9 changes: 9 additions & 0 deletions tests/console/commands/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,15 @@ def test_set_pypi_token_unsuccessful_multiple_values(
assert str(e.value) == "Expected only one argument (token), got 2"


def test_set_pypi_token_no_values(
tester: CommandTester,
) -> None:
with pytest.raises(ValueError) as e:
tester.execute("pypi-token.pypi")

assert str(e.value) == "Expected a value for pypi-token.pypi setting."


def test_set_client_cert(
tester: CommandTester,
auth_config_source: DictConfigSource,
Expand Down

0 comments on commit 30da950

Please sign in to comment.