Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/poetry_plugin_export/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ def handle(self) -> int:
fmt = self.option("format")

if not Exporter.is_format_supported(fmt):
raise ValueError(f"Invalid export format: {fmt}")
raise ValueError(
f"Invalid export format: {fmt}. "
f"Supported formats: {', '.join(sorted(Exporter.EXPORT_METHODS))}"
)

output = self.option("output")

Expand Down
5 changes: 4 additions & 1 deletion src/poetry_plugin_export/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ def with_credentials(self, with_credentials: bool = True) -> Exporter:

def export(self, fmt: str, cwd: Path, output: IO | str) -> None:
if not self.is_format_supported(fmt):
raise ValueError(f"Invalid export format: {fmt}")
raise ValueError(
f"Invalid export format: {fmt}. "
f"Supported formats: {', '.join(sorted(self.EXPORT_METHODS))}"
)

out_dir = cwd
if isinstance(output, str):
Expand Down
8 changes: 7 additions & 1 deletion tests/command/test_command_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,13 @@ def test_export_exports_requirements_txt_uses_lock_file(


def test_export_fails_on_invalid_format(tester: CommandTester, do_lock: None) -> None:
with pytest.raises(ValueError):
with pytest.raises(
ValueError,
match=(
r"Invalid export format: invalid\. Supported formats: "
r"constraints\.txt, pylock\.toml, requirements\.txt"
),
):
tester.execute("--format invalid")


Expand Down
Loading