2
2
from __future__ import annotations
3
3
4
4
import logging
5
+ import re
5
6
import sys
6
7
from typing import TYPE_CHECKING , Any
7
8
@@ -193,25 +194,27 @@ def matchyaml(self, file: Lintable) -> list[MatchError]:
193
194
pytest .param (
194
195
"examples/.collection/galaxy.yml" ,
195
196
"galaxy" ,
196
- [" 'GPL' is not one of" ],
197
+ [r"^ 'GPL' is not one of.*https:// " ],
197
198
id = "galaxy" ,
198
199
),
199
200
pytest .param (
200
201
"examples/roles/invalid_requirements_schema/meta/requirements.yml" ,
201
202
"requirements" ,
202
- ["{'foo': 'bar'} is not valid under any of the given schemas" ],
203
+ [
204
+ r"^{'foo': 'bar'} is not valid under any of the given schemas.*https://" ,
205
+ ],
203
206
id = "requirements" ,
204
207
),
205
208
pytest .param (
206
209
"examples/roles/invalid_meta_schema/meta/main.yml" ,
207
210
"meta" ,
208
- [" False is not of type 'string'" ],
211
+ [r"^ False is not of type 'string'.*https:// " ],
209
212
id = "meta" ,
210
213
),
211
214
pytest .param (
212
215
"examples/playbooks/vars/invalid_vars_schema.yml" ,
213
216
"vars" ,
214
- [" '123' does not match any of the regexes" ],
217
+ [r"^ '123' does not match any of the regexes.*https:// " ],
215
218
id = "vars" ,
216
219
),
217
220
pytest .param (
@@ -223,14 +226,18 @@ def matchyaml(self, file: Lintable) -> list[MatchError]:
223
226
pytest .param (
224
227
"examples/ee_broken/execution-environment.yml" ,
225
228
"execution-environment" ,
226
- ["{'foo': 'bar'} is not valid under any of the given schemas" ],
229
+ [
230
+ r"^{'foo': 'bar'} is not valid under any of the given schemas.*https://" ,
231
+ ],
227
232
id = "execution-environment-broken" ,
228
233
),
229
234
("examples/meta/runtime.yml" , "meta-runtime" , []),
230
235
pytest .param (
231
236
"examples/broken_collection_meta_runtime/meta/runtime.yml" ,
232
237
"meta-runtime" ,
233
- ["Additional properties are not allowed ('foo' was unexpected)" ],
238
+ [
239
+ r"^Additional properties are not allowed \('foo' was unexpected\).*https://" ,
240
+ ],
234
241
id = "meta-runtime-broken" ,
235
242
),
236
243
pytest .param (
@@ -242,7 +249,9 @@ def matchyaml(self, file: Lintable) -> list[MatchError]:
242
249
pytest .param (
243
250
"examples/inventory/broken_dev_inventory.yml" ,
244
251
"inventory" ,
245
- ["Additional properties are not allowed ('foo' was unexpected)" ],
252
+ [
253
+ r"^Additional properties are not allowed \('foo' was unexpected\).*https://" ,
254
+ ],
246
255
id = "inventory-broken" ,
247
256
),
248
257
pytest .param (
@@ -260,7 +269,9 @@ def matchyaml(self, file: Lintable) -> list[MatchError]:
260
269
pytest .param (
261
270
"examples/broken/.ansible-lint" ,
262
271
"ansible-lint-config" ,
263
- ["Additional properties are not allowed ('foo' was unexpected)" ],
272
+ [
273
+ r"^Additional properties are not allowed \('foo' was unexpected\).*https://" ,
274
+ ],
264
275
id = "ansible-lint-config-broken" ,
265
276
),
266
277
pytest .param (
@@ -272,7 +283,9 @@ def matchyaml(self, file: Lintable) -> list[MatchError]:
272
283
pytest .param (
273
284
"examples/broken/ansible-navigator.yml" ,
274
285
"ansible-navigator-config" ,
275
- ["Additional properties are not allowed ('ansible' was unexpected)" ],
286
+ [
287
+ r"^Additional properties are not allowed \('ansible' was unexpected\).*https://" ,
288
+ ],
276
289
id = "ansible-navigator-config-broken" ,
277
290
),
278
291
pytest .param (
@@ -284,20 +297,24 @@ def matchyaml(self, file: Lintable) -> list[MatchError]:
284
297
pytest .param (
285
298
"examples/roles/broken_argument_specs/meta/argument_specs.yml" ,
286
299
"role-arg-spec" ,
287
- ["Additional properties are not allowed ('foo' was unexpected)" ],
300
+ [
301
+ r"^Additional properties are not allowed \('foo' was unexpected\).*https://" ,
302
+ ],
288
303
id = "role-arg-spec-broken" ,
289
304
),
290
305
pytest .param (
291
306
"examples/changelogs/changelog.yaml" ,
292
307
"changelog" ,
293
- ["Additional properties are not allowed ('foo' was unexpected)" ],
308
+ [
309
+ r"^Additional properties are not allowed \('foo' was unexpected\).*https://" ,
310
+ ],
294
311
id = "changelog" ,
295
312
),
296
313
pytest .param (
297
314
"examples/rulebooks/rulebook-fail.yml" ,
298
315
"rulebook" ,
299
316
[
300
- " Additional properties are not allowed ('that_should_not_be_here' was unexpected) " ,
317
+ r"^ Additional properties are not allowed \ ('that_should_not_be_here' was unexpected\).*https:// " ,
301
318
],
302
319
id = "rulebook" ,
303
320
),
@@ -336,7 +353,7 @@ def test_schema(file: str, expected_kind: str, expected: list[str]) -> None:
336
353
assert len (results ) == len (expected ), results
337
354
for idx , result in enumerate (results ):
338
355
assert result .filename .endswith (file )
339
- assert expected [idx ] in result .message
356
+ assert re . match ( expected [idx ], result .message )
340
357
assert result .tag == f"schema[{ expected_kind } ]"
341
358
342
359
@pytest .mark .parametrize (
0 commit comments