pqcli: reject --load-save 0 and negative numbers

`if args.load_save:` treated 0 as unset, so the menu opened instead,
and a negative number indexed from the end of the roster, so -1
played the last character. Both now list the characters and exit
like any other number out of range.
This commit is contained in:
Dash committed 2026-10-17 19:51:19 +02:00
1 parent 60d2c54a88
commit c169102c32
2 files changed
+6 -15

No files matched your search

+2 -10
View File
@@ -90,19 +90,12 @@ def test_list_saves_when_there_are_none(
assert not config.exists()
BAD_LOAD_SAVE = "--load-save 0 and negative numbers are not rejected"
@pytest.mark.parametrize(
"num",
[
"3",
pytest.param(
"0", marks=pytest.mark.xfail(strict=True, reason=BAD_LOAD_SAVE)
),
pytest.param(
"-1", marks=pytest.mark.xfail(strict=True, reason=BAD_LOAD_SAVE)
),
"0",
"-1",
],
)
def test_load_save_rejects_unknown_character(
@@ -113,7 +106,6 @@ def test_load_save_rejects_unknown_character(
num: str,
) -> None:
write_roster(config, hero("Ann"), hero("Bob"))
# 0 falls through to the menu and -1 plays Bob; neither should
feed(monkeypatch, ["7"])
monkeypatch.setattr(BasicUserInterface, "play", lambda self, p: None)
assert run("--basic", "--load-save", num) == 1