Skip to content

Commit 7c575d6

Browse files
committed
parametrize test
1 parent ac6a2ac commit 7c575d6

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

tests/test_shell_completion.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,18 @@ def test_group():
4040
assert _get_words(cli, [], "-") == ["-a", "--help"]
4141

4242

43-
def test_nested_group():
43+
@pytest.mark.parametrize(
44+
("args", "word", "expect"),
45+
[
46+
([], "", ["get"]),
47+
(["get"], "", ["full"]),
48+
(["get", "full"], "", ["data"]),
49+
(["get", "full"], "-", ["--verbose", "--help"]),
50+
(["get", "full", "data"], "", []),
51+
(["get", "full", "data"], "-", ["-a", "--help"]),
52+
],
53+
)
54+
def test_nested_group(args: list[str], word: str, expect: list[str]) -> None:
4455
cli = Group(
4556
"cli",
4657
commands=[
@@ -56,12 +67,7 @@ def test_nested_group():
5667
)
5768
],
5869
)
59-
assert _get_words(cli, [], "") == ["get"]
60-
assert _get_words(cli, ["get"], "") == ["full"]
61-
assert _get_words(cli, ["get", "full"], "") == ["data"]
62-
assert _get_words(cli, ["get", "full"], "-") == ["--verbose", "--help"]
63-
assert _get_words(cli, ["get", "full", "data"], "") == []
64-
assert _get_words(cli, ["get", "full", "data"], "-") == ["-a", "--help"]
70+
assert _get_words(cli, args, word) == expect
6571

6672

6773
def test_group_command_same_option():

0 commit comments

Comments
 (0)