Skip to content

Commit ca8c832

Browse files
committed
refactors tests to use pytest.param()
1 parent 7d6e28d commit ca8c832

File tree

1 file changed

+53
-36
lines changed

1 file changed

+53
-36
lines changed

scripts/microgenerator/tests/unit/test_generate_filters.py

Lines changed: 53 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,42 +9,49 @@
99
@pytest.mark.parametrize(
1010
"class_name, filters, expected",
1111
[
12-
("MyClass", {}, True), # No filters
13-
(
12+
pytest.param("MyClass", {}, True, id="No filters"),
13+
pytest.param(
1414
"DatasetClient",
1515
{"include_suffixes": ["Client", "Service"]},
1616
True,
17-
), # Include suffix match
18-
(
17+
id="Include suffix match",
18+
),
19+
pytest.param(
1920
"MyClass",
2021
{"include_suffixes": ["Client", "Service"]},
2122
False,
22-
), # Include suffix no match
23-
(
23+
id="Include suffix no match",
24+
),
25+
pytest.param(
2426
"MyBase",
2527
{"exclude_suffixes": ["Base", "Util"]},
2628
False,
27-
), # Exclude suffix match
28-
(
29+
id="Exclude suffix match",
30+
),
31+
pytest.param(
2932
"MyClass",
3033
{"exclude_suffixes": ["Base", "Util"]},
3134
True,
32-
), # Exclude suffix no match
33-
(
35+
id="Exclude suffix no match",
36+
),
37+
pytest.param(
3438
"DatasetClient",
3539
{"include_suffixes": ["Client"], "exclude_suffixes": ["BaseClient"]},
3640
True,
37-
), # Mix include/exclude
38-
(
41+
id="Mix include/exclude match",
42+
),
43+
pytest.param(
3944
"BaseClient",
4045
{"include_suffixes": ["Client"], "exclude_suffixes": ["BaseClient"]},
4146
False,
42-
), # Mix include/exclude
43-
(
47+
id="Mix include/exclude no match",
48+
),
49+
pytest.param(
4450
"MyClass",
4551
{"include_suffixes": [], "exclude_suffixes": []},
4652
True,
47-
), # Empty filters
53+
id="Empty filters",
54+
),
4855
],
4956
)
5057
def test_should_include_class(class_name, filters, expected):
@@ -55,57 +62,67 @@ def test_should_include_class(class_name, filters, expected):
5562
@pytest.mark.parametrize(
5663
"method_name, filters, expected",
5764
[
58-
("my_method", {}, True), # No filters
59-
(
65+
pytest.param("my_method", {}, True, id="No filters"),
66+
pytest.param(
6067
"get_dataset",
6168
{"include_prefixes": ["get_", "list_"]},
6269
True,
63-
), # Include prefix match
64-
(
70+
id="Include prefix match (get)",
71+
),
72+
pytest.param(
6573
"list_jobs",
6674
{"include_prefixes": ["get_", "list_"]},
6775
True,
68-
), # Include prefix match
69-
(
76+
id="Include prefix match (list)",
77+
),
78+
pytest.param(
7079
"create_dataset",
7180
{"include_prefixes": ["get_", "list_"]},
7281
False,
73-
), # Include prefix no match
74-
(
82+
id="Include prefix no match",
83+
),
84+
pytest.param(
7585
"_private_method",
7686
{"exclude_prefixes": ["_", "internal_"]},
7787
False,
78-
), # Exclude prefix match
79-
(
88+
id="Exclude prefix match (private)",
89+
),
90+
pytest.param(
8091
"internal_helper",
8192
{"exclude_prefixes": ["_", "internal_"]},
8293
False,
83-
), # Exclude prefix match
84-
(
94+
id="Exclude prefix match (internal)",
95+
),
96+
pytest.param(
8597
"get_dataset",
8698
{"exclude_prefixes": ["_", "internal_"]},
8799
True,
88-
), # Exclude prefix no match
89-
(
100+
id="Exclude prefix no match",
101+
),
102+
pytest.param(
90103
"get_dataset",
91104
{"include_prefixes": ["get_"], "exclude_prefixes": ["get_internal_"]},
92105
True,
93-
), # Mix include/exclude
94-
(
106+
id="Mix include/exclude match",
107+
),
108+
pytest.param(
95109
"get_internal_status",
96110
{"include_prefixes": ["get_"], "exclude_prefixes": ["get_internal_"]},
97111
False,
98-
), # Mix include/exclude
99-
(
112+
id="Mix include/exclude no match (exclude wins)",
113+
),
114+
pytest.param(
100115
"list_datasets",
101116
{"include_prefixes": ["get_"], "exclude_prefixes": ["get_internal_"]},
102117
False,
103-
), # Mix include/exclude
104-
(
118+
id="Mix include/exclude no match (include fails)",
119+
),
120+
pytest.param(
105121
"my_method",
106122
{"include_prefixes": [], "exclude_prefixes": []},
107123
True,
108-
), # Empty filters
124+
id="Empty filters",
125+
),
109126
],
110127
)
111128
def test_should_include_method(method_name, filters, expected):

0 commit comments

Comments
 (0)