@@ -231,12 +231,12 @@ def test_sequence(self):
231
231
# Test error is raised when sequence key is missing
232
232
with pytest .raises (SchemaConflict ) as ex :
233
233
Rule (schema = {"type" : "seq" })
234
- assert ex .value . msg . startswith ( "seq.nosequence" ), "Wrong exception was raised "
234
+ assert str ( ex .value ) == "<SchemaConflict: error code 5: Type is sequence but no sequence alias found on same level: Path: '/'> "
235
235
236
236
# sequence and pattern can't be used at same time
237
237
with pytest .raises (SchemaConflict ) as ex :
238
238
Rule (schema = {"type" : "seq" , "sequence" : [{"type" : "str" }], "pattern" : "..." })
239
- assert ex .value . msg . startswith ( "seq.conflict :: pattern" ), "Wrong exception was raised "
239
+ assert str ( ex .value ) == "<SchemaConflict: error code 5: Sequence and pattern can't be on the same level in the schema: Path: '/'> "
240
240
241
241
def test_build_sequence_multiple_values (self ):
242
242
"""
@@ -276,7 +276,7 @@ def test_mapping(self):
276
276
# when type is specefied, 'mapping' key must be present
277
277
with pytest .raises (SchemaConflict ) as ex :
278
278
Rule (schema = {"type" : "map" })
279
- assert ex .value . msg . startswith ( "map.nomapping" ), "Wrong exception was raised "
279
+ assert str ( ex .value ) == "<SchemaConflict: error code 5: Type is mapping but no mapping alias found on same level: Path: '/'> "
280
280
281
281
# 'map' and 'enum' can't be used at same time
282
282
# TODO: This do not work because it currently raises RuleError: <RuleError: error code 4: enum.notscalar>
@@ -295,24 +295,29 @@ def test_check_conflicts(self):
295
295
# Test sequence and mapping can't be used at same level
296
296
with pytest .raises (SchemaConflict ) as ex :
297
297
Rule (schema = {"type" : "seq" , "sequence" : [{"type" : "str" }], "mapping" : {"name" : {"type" : "str" , "pattern" : ".+@.+" }}})
298
- assert ex .value .msg .startswith ("seq.conflict :: mapping" ), "Wrong exception was raised"
298
+ assert str (ex .value ) == "<SchemaConflict: error code 5: Sequence and mapping can't be on the same level in the schema: Path: '/'>"
299
+ assert ex .value .error_key == 'seq.conflict.mapping'
299
300
300
301
# Mapping and sequence can't used at same time
301
302
with pytest .raises (SchemaConflict ) as ex :
302
303
Rule (schema = {"type" : "map" , "mapping" : {"foo" : {"type" : "str" }}, "sequence" : [{"type" : "str" }]})
303
- assert ex .value .msg .startswith ("map.conflict :: mapping" ), "Wrong exception was raised"
304
+ assert str (ex .value ) == "<SchemaConflict: error code 5: Mapping and sequence can't be on the same level in the schema: Path: '/'>"
305
+ assert ex .value .error_key == 'map.conflict.sequence'
304
306
305
307
# scalar type and sequence can't be used at same time
306
308
with pytest .raises (SchemaConflict ) as ex :
307
309
Rule (schema = {"type" : "int" , "sequence" : [{"type" : "str" }]})
308
- assert ex .value .msg .startswith ("scalar.conflict :: sequence" ), "Wrong exception was raised"
310
+ assert str (ex .value ) == "<SchemaConflict: error code 5: Scalar and sequence can't be on the same level in the schema: Path: '/'>"
311
+ assert ex .value .error_key == 'scalar.conflict.sequence'
309
312
310
313
# scalar type and mapping can't be used at same time
311
314
with pytest .raises (SchemaConflict ) as ex :
312
315
Rule (schema = {"type" : "int" , "mapping" : {"foo" : {"type" : "str" }}})
313
- assert ex .value .msg .startswith ("scalar.conflict :: mapping" ), "Wrong exception was raised"
316
+ assert str (ex .value ) == "<SchemaConflict: error code 5: Scalar and mapping can't be on the same level in the schema: Path: '/'>"
317
+ assert ex .value .error_key == 'scalar.conflict.mapping'
314
318
315
319
# scalar type and enum can't be used at same time
316
320
with pytest .raises (SchemaConflict ) as ex :
317
321
Rule (schema = {"type" : "int" , "enum" : [1 , 2 , 3 ], "range" : {"max" : 10 , "min" : 1 }})
318
- assert ex .value .msg .startswith ("enum.conflict :: range" ), "Wrong exception was raised"
322
+ assert str (ex .value ) == "<SchemaConflict: error code 5: Enum and range can't be on the same level in the schema: Path: '/'>"
323
+ assert ex .value .error_key == 'enum.conflict.range'
0 commit comments