|
22 | 22 | import _pytest.capture
|
23 | 23 |
|
24 | 24 |
|
| 25 | +class PureNameTestFixture(t.NamedTuple): |
| 26 | + """Test fixture for verifying pure name path validation.""" |
| 27 | + |
| 28 | + test_id: str |
| 29 | + path: str |
| 30 | + expect: bool |
| 31 | + |
| 32 | + |
| 33 | +PURE_NAME_TEST_FIXTURES: list[PureNameTestFixture] = [ |
| 34 | + PureNameTestFixture( |
| 35 | + test_id="current_dir", |
| 36 | + path=".", |
| 37 | + expect=False, |
| 38 | + ), |
| 39 | + PureNameTestFixture( |
| 40 | + test_id="current_dir_slash", |
| 41 | + path="./", |
| 42 | + expect=False, |
| 43 | + ), |
| 44 | + PureNameTestFixture( |
| 45 | + test_id="empty_path", |
| 46 | + path="", |
| 47 | + expect=False, |
| 48 | + ), |
| 49 | + PureNameTestFixture( |
| 50 | + test_id="tmuxp_yaml", |
| 51 | + path=".tmuxp.yaml", |
| 52 | + expect=False, |
| 53 | + ), |
| 54 | + PureNameTestFixture( |
| 55 | + test_id="parent_tmuxp_yaml", |
| 56 | + path="../.tmuxp.yaml", |
| 57 | + expect=False, |
| 58 | + ), |
| 59 | + PureNameTestFixture( |
| 60 | + test_id="parent_dir", |
| 61 | + path="../", |
| 62 | + expect=False, |
| 63 | + ), |
| 64 | + PureNameTestFixture( |
| 65 | + test_id="absolute_path", |
| 66 | + path="/hello/world", |
| 67 | + expect=False, |
| 68 | + ), |
| 69 | + PureNameTestFixture( |
| 70 | + test_id="home_tmuxp_path", |
| 71 | + path="~/.tmuxp/hey", |
| 72 | + expect=False, |
| 73 | + ), |
| 74 | + PureNameTestFixture( |
| 75 | + test_id="home_work_path", |
| 76 | + path="~/work/c/tmux/", |
| 77 | + expect=False, |
| 78 | + ), |
| 79 | + PureNameTestFixture( |
| 80 | + test_id="home_work_tmuxp_yaml", |
| 81 | + path="~/work/c/tmux/.tmuxp.yaml", |
| 82 | + expect=False, |
| 83 | + ), |
| 84 | + PureNameTestFixture( |
| 85 | + test_id="pure_name", |
| 86 | + path="myproject", |
| 87 | + expect=True, |
| 88 | + ), |
| 89 | +] |
| 90 | + |
| 91 | + |
25 | 92 | def test_in_dir_from_config_dir(tmp_path: pathlib.Path) -> None:
|
26 | 93 | """config.in_dir() finds configs config dir."""
|
27 | 94 | cli.startup(tmp_path)
|
@@ -64,22 +131,15 @@ def test_get_configs_cwd(
|
64 | 131 |
|
65 | 132 |
|
66 | 133 | @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], |
81 | 137 | )
|
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: |
83 | 143 | """Test is_pure_name() is truthy when file, not directory or config alias."""
|
84 | 144 | assert is_pure_name(path) == expect
|
85 | 145 |
|
|
0 commit comments