Skip to content

Commit ac908b7

Browse files
authored
Test suite: Move tests to typing.NamedTuple (#423)
2 parents 05b6b1f + 5c073d4 commit ac908b7

File tree

2 files changed

+68
-33
lines changed

2 files changed

+68
-33
lines changed

CHANGES

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ $ pipx install --suffix=@next 'vcspull' --pip-args '\--pre' --force
2121

2222
<!-- Maintainers, insert changes / features for the next release here -->
2323

24+
### Development
25+
26+
- Refactor of two testsuites to used `NamedTuple` parametrization (#423):
27+
28+
- test_config_variations
29+
- test_updating_remote
30+
2431
### Breaking changes
2532

2633
- Python 3.7 Dropped (#421)

tests/test_sync.py

Lines changed: 61 additions & 33 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="expanded_repo_style",
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="expanded_repo_style_with_remote",
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"""
@@ -131,39 +145,53 @@ def test_config_variations(
131145
assert current_remote.fetch_url == repo_url
132146

133147

134-
@pytest.mark.parametrize(
135-
"config_tpl,has_extra_remotes",
136-
[
137-
[
138-
"""
148+
class UpdatingRemoteFixture(t.NamedTuple):
149+
test_id: str
150+
config_tpl: str
151+
has_extra_remotes: bool
152+
153+
154+
UPDATING_REMOTE_FIXTURES = [
155+
UpdatingRemoteFixture(
156+
test_id="no_remotes",
157+
config_tpl="""
139158
{tmp_path}/study/myrepo:
140159
{CLONE_NAME}: git+file://{dir}
141160
""",
142-
False,
143-
],
144-
[
145-
"""
161+
has_extra_remotes=False,
162+
),
163+
UpdatingRemoteFixture(
164+
test_id="no_remotes_expanded_repo_style",
165+
config_tpl="""
146166
{tmp_path}/study/myrepo:
147167
{CLONE_NAME}:
148168
repo: git+file://{dir}
149169
""",
150-
False,
151-
],
152-
[
153-
"""
170+
has_extra_remotes=False,
171+
),
172+
UpdatingRemoteFixture(
173+
test_id="has_remotes_expanded_repo_style",
174+
config_tpl="""
154175
{tmp_path}/study/myrepo:
155176
{CLONE_NAME}:
156177
repo: git+file://{dir}
157178
remotes:
158179
mirror_repo: git+file://{dir}
159180
""",
160-
True,
161-
],
162-
],
181+
has_extra_remotes=True,
182+
),
183+
]
184+
185+
186+
@pytest.mark.parametrize(
187+
list(UpdatingRemoteFixture._fields),
188+
UPDATING_REMOTE_FIXTURES,
189+
ids=[test.test_id for test in UPDATING_REMOTE_FIXTURES],
163190
)
164191
def test_updating_remote(
165192
tmp_path: pathlib.Path,
166193
create_git_remote_repo: CreateProjectCallbackFixtureProtocol,
194+
test_id: str,
167195
config_tpl: str,
168196
has_extra_remotes: bool,
169197
) -> None:

0 commit comments

Comments
 (0)