Skip to content

Commit b350e44

Browse files
committed
refactor(test_config_variations): Use NamedTuple parameterize style
1 parent 05b6b1f commit b350e44

File tree

1 file changed

+31
-17
lines changed

1 file changed

+31
-17
lines changed

tests/test_sync.py

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -62,41 +62,55 @@ def write_config_remote(
6262
)
6363

6464

65-
@pytest.mark.parametrize(
66-
"config_tpl,remote_list",
67-
[
68-
[
69-
"""
65+
class ConfigVariationTest(t.NamedTuple):
66+
test_id: str
67+
config_tpl: str
68+
remote_list: list[str]
69+
70+
71+
CONFIG_VARIATION_FIXTURES = [
72+
ConfigVariationTest(
73+
test_id="default",
74+
config_tpl="""
7075
{tmp_path}/study/myrepo:
7176
{CLONE_NAME}: git+file://{dir}
7277
""",
73-
["origin"],
74-
],
75-
[
76-
"""
78+
remote_list=["origin"],
79+
),
80+
ConfigVariationTest(
81+
test_id="two",
82+
config_tpl="""
7783
{tmp_path}/study/myrepo:
7884
{CLONE_NAME}:
7985
repo: git+file://{dir}
8086
""",
81-
["repo"],
82-
],
83-
[
84-
"""
87+
remote_list=["repo"],
88+
),
89+
ConfigVariationTest(
90+
test_id="three",
91+
config_tpl="""
8592
{tmp_path}/study/myrepo:
8693
{CLONE_NAME}:
8794
repo: git+file://{dir}
8895
remotes:
8996
secondremote: git+file://{dir}
9097
""",
91-
["secondremote"],
92-
],
93-
],
98+
remote_list=["secondremote"],
99+
),
100+
]
101+
102+
103+
@pytest.mark.parametrize(
104+
list(ConfigVariationTest._fields),
105+
CONFIG_VARIATION_FIXTURES,
106+
ids=[test.test_id for test in CONFIG_VARIATION_FIXTURES],
94107
)
95108
def test_config_variations(
96109
tmp_path: pathlib.Path,
110+
capsys: pytest.CaptureFixture[str],
97111
create_git_remote_repo: CreateProjectCallbackFixtureProtocol,
112+
test_id: str,
98113
config_tpl: str,
99-
capsys: pytest.CaptureFixture[str],
100114
remote_list: list[str],
101115
) -> None:
102116
"""Test config output with variation of config formats"""

0 commit comments

Comments
 (0)