Skip to content

Commit 05aec2e

Browse files
committed
tests(cli): Use NamedTuple for fixtures
1 parent 1904def commit 05aec2e

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tests/test_cli.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,41 @@ def get_output(
2727
(["g", "--help"], "git --help"),
2828
],
2929
)
30+
class CommandLineTestFixture(t.NamedTuple):
31+
"""Test fixture for CLI params, environment, and expected result."""
32+
33+
# pytest internal
34+
test_id: str
35+
36+
# test data
37+
argv_args: t.List[str]
38+
39+
# results
40+
expect_cmd: str
41+
42+
43+
TEST_FIXTURES: t.List[CommandLineTestFixture] = [
44+
CommandLineTestFixture(
45+
test_id="g-cmd-inside-git-dir",
46+
argv_args=["g"],
47+
expect_cmd="git",
48+
),
49+
CommandLineTestFixture(
50+
test_id="g-cmd-help-inside-git-dir",
51+
argv_args=["g --help"],
52+
expect_cmd="git --help",
53+
),
54+
]
55+
56+
57+
@pytest.mark.parametrize(
58+
list(CommandLineTestFixture._fields),
59+
TEST_FIXTURES,
60+
ids=[f.test_id for f in TEST_FIXTURES],
61+
)
3062
def test_command_line(
3163
# capsys: pytest.CaptureFixture[str],
64+
test_id: str,
3265
argv_args: t.List[str],
3366
expect_cmd: str,
3467
) -> None:

0 commit comments

Comments
 (0)