Skip to content

Commit 5081671

Browse files
committed
refactor(tests): convert test_convert.py tests to use NamedTuple fixtures
1 parent 7faf619 commit 5081671

File tree

1 file changed

+62
-14
lines changed

1 file changed

+62
-14
lines changed

tests/cli/test_convert.py

+62-14
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,44 @@
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+
CONVERT_TEST_FIXTURES: list[ConvertTestFixture] = [
26+
ConvertTestFixture(
27+
test_id="convert_current_dir",
28+
cli_args=["convert", "."],
29+
),
30+
ConvertTestFixture(
31+
test_id="convert_yaml_file",
32+
cli_args=["convert", ".tmuxp.yaml"],
33+
),
34+
ConvertTestFixture(
35+
test_id="convert_yaml_file_auto_confirm",
36+
cli_args=["convert", ".tmuxp.yaml", "-y"],
37+
),
38+
ConvertTestFixture(
39+
test_id="convert_yml_file",
40+
cli_args=["convert", ".tmuxp.yml"],
41+
),
42+
ConvertTestFixture(
43+
test_id="convert_yml_file_auto_confirm",
44+
cli_args=["convert", ".tmuxp.yml", "-y"],
45+
),
46+
]
47+
48+
1849
@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-
],
50+
list(ConvertTestFixture._fields),
51+
CONVERT_TEST_FIXTURES,
52+
ids=[test.test_id for test in CONVERT_TEST_FIXTURES],
2753
)
2854
def test_convert(
55+
test_id: str,
2956
cli_args: list[str],
3057
tmp_path: pathlib.Path,
3158
monkeypatch: pytest.MonkeyPatch,
@@ -57,15 +84,36 @@ def test_convert(
5784
assert tmuxp_json.open().read() == json.dumps({"session_name": "hello"}, indent=2)
5885

5986

87+
class ConvertJsonTestFixture(t.NamedTuple):
88+
"""Test fixture for tmuxp convert json command tests."""
89+
90+
test_id: str
91+
cli_args: list[str]
92+
93+
94+
CONVERT_JSON_TEST_FIXTURES: list[ConvertJsonTestFixture] = [
95+
ConvertJsonTestFixture(
96+
test_id="convert_json_current_dir",
97+
cli_args=["convert", "."],
98+
),
99+
ConvertJsonTestFixture(
100+
test_id="convert_json_file",
101+
cli_args=["convert", ".tmuxp.json"],
102+
),
103+
ConvertJsonTestFixture(
104+
test_id="convert_json_file_auto_confirm",
105+
cli_args=["convert", ".tmuxp.json", "-y"],
106+
),
107+
]
108+
109+
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)