Skip to content

Commit 6192ee5

Browse files
committed
refactor(tests): convert test_finder.py pure name test to use NamedTuple fixtures
1 parent 434d30d commit 6192ee5

File tree

1 file changed

+75
-15
lines changed

1 file changed

+75
-15
lines changed

tests/workspace/test_finder.py

Lines changed: 75 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,23 +63,83 @@ def test_get_configs_cwd(
6363
assert ".tmuxp.json" in configs_found
6464

6565

66+
class PureNameTestFixture(t.NamedTuple):
67+
"""Test fixture for verifying pure name path validation."""
68+
69+
test_id: str
70+
path: str
71+
expect: bool
72+
73+
74+
PURE_NAME_TEST_FIXTURES: list[PureNameTestFixture] = [
75+
PureNameTestFixture(
76+
test_id="current_dir",
77+
path=".",
78+
expect=False,
79+
),
80+
PureNameTestFixture(
81+
test_id="current_dir_slash",
82+
path="./",
83+
expect=False,
84+
),
85+
PureNameTestFixture(
86+
test_id="empty_path",
87+
path="",
88+
expect=False,
89+
),
90+
PureNameTestFixture(
91+
test_id="tmuxp_yaml",
92+
path=".tmuxp.yaml",
93+
expect=False,
94+
),
95+
PureNameTestFixture(
96+
test_id="parent_tmuxp_yaml",
97+
path="../.tmuxp.yaml",
98+
expect=False,
99+
),
100+
PureNameTestFixture(
101+
test_id="parent_dir",
102+
path="../",
103+
expect=False,
104+
),
105+
PureNameTestFixture(
106+
test_id="absolute_path",
107+
path="/hello/world",
108+
expect=False,
109+
),
110+
PureNameTestFixture(
111+
test_id="home_tmuxp_path",
112+
path="~/.tmuxp/hey",
113+
expect=False,
114+
),
115+
PureNameTestFixture(
116+
test_id="home_work_path",
117+
path="~/work/c/tmux/",
118+
expect=False,
119+
),
120+
PureNameTestFixture(
121+
test_id="home_work_tmuxp_yaml",
122+
path="~/work/c/tmux/.tmuxp.yaml",
123+
expect=False,
124+
),
125+
PureNameTestFixture(
126+
test_id="pure_name",
127+
path="myproject",
128+
expect=True,
129+
),
130+
]
131+
132+
66133
@pytest.mark.parametrize(
67-
("path", "expect"),
68-
[
69-
(".", False),
70-
("./", False),
71-
("", False),
72-
(".tmuxp.yaml", False),
73-
("../.tmuxp.yaml", False),
74-
("../", False),
75-
("/hello/world", False),
76-
("~/.tmuxp/hey", False),
77-
("~/work/c/tmux/", False),
78-
("~/work/c/tmux/.tmuxp.yaml", False),
79-
("myproject", True),
80-
],
134+
list(PureNameTestFixture._fields),
135+
PURE_NAME_TEST_FIXTURES,
136+
ids=[test.test_id for test in PURE_NAME_TEST_FIXTURES],
81137
)
82-
def test_is_pure_name(path: str, expect: bool) -> None:
138+
def test_is_pure_name(
139+
test_id: str,
140+
path: str,
141+
expect: bool,
142+
) -> None:
83143
"""Test is_pure_name() is truthy when file, not directory or config alias."""
84144
assert is_pure_name(path) == expect
85145

0 commit comments

Comments
 (0)