Skip to content

Commit 1e9635e

Browse files
committed
Make sure select_choices returns a list
Returning a tuple would be a bit unexpecetd here I think
1 parent da6cb98 commit 1e9635e

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

cli_ui/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ def select_choices(
588588
continue
589589

590590
try:
591-
res = itemgetter(*index)(choices)
591+
res = list(itemgetter(*index)(choices))
592592
except Exception:
593593
info("Please enter valid selection number(s)")
594594
continue

cli_ui/tests/test_cli_ui.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,15 @@ def test_select_choices_empty_input() -> None:
353353
assert res is None
354354

355355

356+
def test_select_choices_using_space_separator() -> None:
357+
with mock.patch("builtins.input") as m:
358+
m.side_effect = ["1 3"]
359+
res = cli_ui.select_choices(
360+
"Select a animal", choices=["cat", "dog", "cow"], sort=False
361+
)
362+
assert res == ["cat", "cow"]
363+
364+
356365
def test_select_choices_ctrl_c() -> None:
357366
with pytest.raises(KeyboardInterrupt):
358367
with mock.patch("builtins.input") as m:

0 commit comments

Comments
 (0)