Skip to content

Commit 01c3908

Browse files
committed
refactor(tests): convert test_convert.py tests to use NamedTuple fixtures
1 parent 0b40c97 commit 01c3908

File tree

1 file changed

+62
-14
lines changed

1 file changed

+62
-14
lines changed

tests/cli/test_convert.py

Lines changed: 62 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,67 @@
1515
import pathlib
1616

1717

18+
class ConvertTestFixture(t.NamedTuple):
19+
"""Test fixture for tmuxp convert command tests."""
20+
21+
test_id: str
22+
cli_args: list[str]
23+
24+
25+
class ConvertJsonTestFixture(t.NamedTuple):
26+
"""Test fixture for tmuxp convert json command tests."""
27+
28+
test_id: str
29+
cli_args: list[str]
30+
31+
32+
CONVERT_TEST_FIXTURES: list[ConvertTestFixture] = [
33+
ConvertTestFixture(
34+
test_id="convert_current_dir",
35+
cli_args=["convert", "."],
36+
),
37+
ConvertTestFixture(
38+
test_id="convert_yaml_file",
39+
cli_args=["convert", ".tmuxp.yaml"],
40+
),
41+
ConvertTestFixture(
42+
test_id="convert_yaml_file_auto_confirm",
43+
cli_args=["convert", ".tmuxp.yaml", "-y"],
44+
),
45+
ConvertTestFixture(
46+
test_id="convert_yml_file",
47+
cli_args=["convert", ".tmuxp.yml"],
48+
),
49+
ConvertTestFixture(
50+
test_id="convert_yml_file_auto_confirm",
51+
cli_args=["convert", ".tmuxp.yml", "-y"],
52+
),
53+
]
54+
55+
56+
CONVERT_JSON_TEST_FIXTURES: list[ConvertJsonTestFixture] = [
57+
ConvertJsonTestFixture(
58+
test_id="convert_json_current_dir",
59+
cli_args=["convert", "."],
60+
),
61+
ConvertJsonTestFixture(
62+
test_id="convert_json_file",
63+
cli_args=["convert", ".tmuxp.json"],
64+
),
65+
ConvertJsonTestFixture(
66+
test_id="convert_json_file_auto_confirm",
67+
cli_args=["convert", ".tmuxp.json", "-y"],
68+
),
69+
]
70+
71+
1872
@pytest.mark.parametrize(
19-
"cli_args",
20-
[
21-
(["convert", "."]),
22-
(["convert", ".tmuxp.yaml"]),
23-
(["convert", ".tmuxp.yaml", "-y"]),
24-
(["convert", ".tmuxp.yml"]),
25-
(["convert", ".tmuxp.yml", "-y"]),
26-
],
73+
list(ConvertTestFixture._fields),
74+
CONVERT_TEST_FIXTURES,
75+
ids=[test.test_id for test in CONVERT_TEST_FIXTURES],
2776
)
2877
def test_convert(
78+
test_id: str,
2979
cli_args: list[str],
3080
tmp_path: pathlib.Path,
3181
monkeypatch: pytest.MonkeyPatch,
@@ -58,14 +108,12 @@ def test_convert(
58108

59109

60110
@pytest.mark.parametrize(
61-
"cli_args",
62-
[
63-
(["convert", "."]),
64-
(["convert", ".tmuxp.json"]),
65-
(["convert", ".tmuxp.json", "-y"]),
66-
],
111+
list(ConvertJsonTestFixture._fields),
112+
CONVERT_JSON_TEST_FIXTURES,
113+
ids=[test.test_id for test in CONVERT_JSON_TEST_FIXTURES],
67114
)
68115
def test_convert_json(
116+
test_id: str,
69117
cli_args: list[str],
70118
tmp_path: pathlib.Path,
71119
monkeypatch: pytest.MonkeyPatch,

0 commit comments

Comments
 (0)