@@ -32,13 +32,18 @@ def validator_max():
3232def validator_aok (request ):
3333 return IntegerValidator ("prop" , "parent" , min = - 2 , max = 10 , array_ok = True )
3434
35+
3536@pytest .fixture
3637def validator_extras ():
37- return IntegerValidator ("prop" , "parent" , min = - 2 , max = 10 , extras = ['normal' , 'bold' ])
38+ return IntegerValidator ("prop" , "parent" , min = - 2 , max = 10 , extras = ["normal" , "bold" ])
39+
3840
3941@pytest .fixture
4042def validator_extras_aok ():
41- return IntegerValidator ("prop" , "parent" , min = - 2 , max = 10 , array_ok = True , extras = ['normal' , 'bold' ])
43+ return IntegerValidator (
44+ "prop" , "parent" , min = - 2 , max = 10 , array_ok = True , extras = ["normal" , "bold" ]
45+ )
46+
4247
4348# ### Acceptance ###
4449@pytest .mark .parametrize ("val" , [1 , - 19 , 0 , - 1234 ])
@@ -63,24 +68,28 @@ def test_rejection_by_value(val, validator):
6368def test_acceptance_min_max (val , validator_min_max ):
6469 assert validator_min_max .validate_coerce (val ) == approx (val )
6570
71+
6672# With extras
67- @pytest .mark .parametrize ("val" , [' normal' , ' bold' , 10 , - 2 ])
73+ @pytest .mark .parametrize ("val" , [" normal" , " bold" , 10 , - 2 ])
6874def test_acceptance_extras (val , validator_extras ):
6975 assert validator_extras .validate_coerce (val ) == val
7076
77+
7178# Test extras for array_ok
72- @pytest .mark .parametrize ("val" , [[10 , ' normal' , ' bold' ], [' normal' ], [10 , - 2 ], [5 ]])
79+ @pytest .mark .parametrize ("val" , [[10 , " normal" , " bold" ], [" normal" ], [10 , - 2 ], [5 ]])
7380def test_acceptance_extras_array (val , validator_extras_aok ):
7481 assert validator_extras_aok .validate_coerce (val ) == val
7582
83+
7684# Test rejection by extras
77- @pytest .mark .parametrize ("val" , [' invalid value' , ' different invalid value' , - 3 , 11 ])
85+ @pytest .mark .parametrize ("val" , [" invalid value" , " different invalid value" , - 3 , 11 ])
7886def test_rejection_extras (val , validator_extras ):
7987 with pytest .raises (ValueError ) as validation_failure :
8088 validator_extras .validate_coerce (val )
8189
8290 assert "Invalid value" in str (validation_failure .value )
8391
92+
8493@pytest .mark .parametrize (
8594 "val" , [- 1.01 , - 10 , 2.1 , 3 , np .iinfo (int ).max , np .iinfo (int ).min ]
8695)
0 commit comments