File tree 1 file changed +38
-10
lines changed 1 file changed +38
-10
lines changed Original file line number Diff line number Diff line change @@ -397,21 +397,49 @@ def f(v: int) -> int:
397
397
)
398
398
399
399
400
- def test_list_fail_fast ():
401
- s = core_schema .list_schema (core_schema .int_schema (), fail_fast = True )
400
+ @pytest .mark .parametrize (
401
+ 'fail_fast,expected' ,
402
+ [
403
+ pytest .param (
404
+ True ,
405
+ [
406
+ {
407
+ 'type' : 'int_parsing' ,
408
+ 'loc' : (1 ,),
409
+ 'msg' : 'Input should be a valid integer, unable to parse string as an integer' ,
410
+ 'input' : 'not-num' ,
411
+ }
412
+ ],
413
+ id = 'fail_fast' ,
414
+ ),
415
+ pytest .param (
416
+ False ,
417
+ [
418
+ {
419
+ 'type' : 'int_parsing' ,
420
+ 'loc' : (1 ,),
421
+ 'msg' : 'Input should be a valid integer, unable to parse string as an integer' ,
422
+ 'input' : 'not-num' ,
423
+ },
424
+ {
425
+ 'type' : 'int_parsing' ,
426
+ 'loc' : (2 ,),
427
+ 'msg' : 'Input should be a valid integer, unable to parse string as an integer' ,
428
+ 'input' : 'again' ,
429
+ },
430
+ ],
431
+ id = 'not_fail_fast' ,
432
+ ),
433
+ ],
434
+ )
435
+ def test_list_fail_fast (fail_fast , expected ):
436
+ s = core_schema .list_schema (core_schema .int_schema (), fail_fast = fail_fast )
402
437
v = SchemaValidator (s )
403
438
404
439
with pytest .raises (ValidationError ) as exc_info :
405
440
v .validate_python ([1 , 'not-num' , 'again' ])
406
441
407
- assert exc_info .value .errors (include_url = False ) == [
408
- {
409
- 'type' : 'int_parsing' ,
410
- 'loc' : (1 ,),
411
- 'msg' : 'Input should be a valid integer, unable to parse string as an integer' ,
412
- 'input' : 'not-num' ,
413
- }
414
- ]
442
+ assert exc_info .value .errors (include_url = False ) == expected
415
443
416
444
417
445
class MySequence (collections .abc .Sequence ):
You can’t perform that action at this time.
0 commit comments