Commit b15cd74
committed
python: allow adding parameter names to parametrized test IDs
By default, only the parameter's values make it into parametrized test
IDs. The parameter names don't. Since parameter values do not always
speak for themselves, the test function + test ID are often not
descriptive/expressive.
Allowing parameter name=value pairs in the test ID optionally to get an idea
what parameters a test gets passed is beneficial. So add a kwarg
`id_names` to @pytest.mark.parametrize() / pytest.Metafunc.parametrize(). It defaults
to `False` to keep the auto-generated ID as before. If set to `True`,
the argument parameter=value pairs in the auto-generated test
IDs are enabled. Calling parametrize() with `ids` and `id_names=True` is
considered an error.
Auto-generated test ID with `id_names=False` (default behavior as
before):
test_something[100-10-True-False-True]
Test ID with `id_names=True`:
test_something[speed_down=100-speed_up=10-foo=True-bar=False-baz=True]
Signed-off-by: Bastian Krause <bst@pengutronix.de>1 parent 5d58b1f commit b15cd74
File tree
5 files changed
+83
-27
lines changed- changelog
- doc/en/example
- src/_pytest
- testing/python
5 files changed
+83
-27
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
| 114 | + | |
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
120 | 126 | | |
121 | 127 | | |
122 | 128 | | |
123 | 129 | | |
124 | 130 | | |
125 | 131 | | |
126 | 132 | | |
127 | | - | |
| 133 | + | |
128 | 134 | | |
129 | 135 | | |
130 | 136 | | |
| |||
140 | 146 | | |
141 | 147 | | |
142 | 148 | | |
143 | | - | |
| 149 | + | |
144 | 150 | | |
145 | 151 | | |
146 | 152 | | |
147 | 153 | | |
148 | 154 | | |
149 | | - | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
150 | 159 | | |
151 | 160 | | |
152 | | - | |
| 161 | + | |
153 | 162 | | |
154 | 163 | | |
155 | 164 | | |
| |||
160 | 169 | | |
161 | 170 | | |
162 | 171 | | |
163 | | - | |
| 172 | + | |
164 | 173 | | |
165 | 174 | | |
166 | 175 | | |
167 | 176 | | |
168 | 177 | | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
179 | 190 | | |
180 | 191 | | |
181 | 192 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
884 | 884 | | |
885 | 885 | | |
886 | 886 | | |
887 | | - | |
| 887 | + | |
888 | 888 | | |
889 | 889 | | |
890 | 890 | | |
891 | | - | |
| 891 | + | |
| 892 | + | |
892 | 893 | | |
893 | 894 | | |
894 | 895 | | |
895 | 896 | | |
896 | 897 | | |
897 | 898 | | |
898 | | - | |
| 899 | + | |
899 | 900 | | |
900 | 901 | | |
901 | 902 | | |
| |||
919 | 920 | | |
920 | 921 | | |
921 | 922 | | |
922 | | - | |
| 923 | + | |
923 | 924 | | |
924 | 925 | | |
925 | 926 | | |
| |||
930 | 931 | | |
931 | 932 | | |
932 | 933 | | |
| 934 | + | |
933 | 935 | | |
934 | | - | |
| 936 | + | |
935 | 937 | | |
936 | 938 | | |
937 | 939 | | |
| |||
948 | 950 | | |
949 | 951 | | |
950 | 952 | | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
951 | 958 | | |
952 | 959 | | |
953 | 960 | | |
| |||
1141 | 1148 | | |
1142 | 1149 | | |
1143 | 1150 | | |
| 1151 | + | |
1144 | 1152 | | |
1145 | 1153 | | |
1146 | 1154 | | |
| |||
1205 | 1213 | | |
1206 | 1214 | | |
1207 | 1215 | | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
1208 | 1221 | | |
1209 | 1222 | | |
1210 | 1223 | | |
| |||
1228 | 1241 | | |
1229 | 1242 | | |
1230 | 1243 | | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
1231 | 1247 | | |
1232 | 1248 | | |
1233 | 1249 | | |
| |||
1237 | 1253 | | |
1238 | 1254 | | |
1239 | 1255 | | |
1240 | | - | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
1241 | 1261 | | |
1242 | 1262 | | |
1243 | 1263 | | |
| |||
1322 | 1342 | | |
1323 | 1343 | | |
1324 | 1344 | | |
| 1345 | + | |
1325 | 1346 | | |
1326 | 1347 | | |
1327 | 1348 | | |
| |||
1356 | 1377 | | |
1357 | 1378 | | |
1358 | 1379 | | |
1359 | | - | |
| 1380 | + | |
1360 | 1381 | | |
1361 | 1382 | | |
1362 | 1383 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
202 | | - | |
| 202 | + | |
| 203 | + | |
203 | 204 | | |
204 | 205 | | |
205 | 206 | | |
206 | 207 | | |
207 | 208 | | |
208 | 209 | | |
209 | | - | |
| 210 | + | |
210 | 211 | | |
211 | | - | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
212 | 221 | | |
213 | | - | |
| 222 | + | |
| 223 | + | |
214 | 224 | | |
215 | 225 | | |
216 | 226 | | |
| |||
221 | 231 | | |
222 | 232 | | |
223 | 233 | | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
224 | 246 | | |
225 | 247 | | |
226 | 248 | | |
| |||
0 commit comments