fix: report an invalid --port with a short message instead of listing every choice
This commit is contained in:
1 parent
c73a7cc3ce
commit
a3222d5ebe
2 files changed
+25
-2
No files matched your search
@@ -33,3 +33,16 @@ def test_package_version_matches_pyproject() -> None:
|
||||
|
||||
data = tomllib.loads((Path(__file__).parent.parent / "pyproject.toml").read_text())
|
||||
assert data["project"]["version"] == __version__
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", ["0", "65536", "-1", "http", "80.5"])
|
||||
def test_serve_rejects_bad_ports_with_a_short_message(
|
||||
value: str, capsys: pytest.CaptureFixture[str]
|
||||
) -> None:
|
||||
with pytest.raises(SystemExit) as exit_info:
|
||||
build_parser().parse_args(["serve", "--port", value])
|
||||
|
||||
err = capsys.readouterr().err
|
||||
assert exit_info.value.code == 2
|
||||
assert "--port" in err and "65535" in err
|
||||
assert len(err) < 500
|
||||
Reference in new issue
Block a user