@@ -32,6 +32,9 @@ def validator_max():
32
32
def validator_aok (request ):
33
33
return IntegerValidator ("prop" , "parent" , min = - 2 , max = 10 , array_ok = True )
34
34
35
+ @pytest .fixture
36
+ def validator_extras ():
37
+ return IntegerValidator ("prop" , "parent" , extras = ['normal' , 'bold' ])
35
38
36
39
# ### Acceptance ###
37
40
@pytest .mark .parametrize ("val" , [1 , - 19 , 0 , - 1234 ])
@@ -56,6 +59,18 @@ def test_rejection_by_value(val, validator):
56
59
def test_acceptance_min_max (val , validator_min_max ):
57
60
assert validator_min_max .validate_coerce (val ) == approx (val )
58
61
62
+ # With extras
63
+ @pytest .mark .parametrize ("val" , ['normal' , 'bold' ])
64
+ def test_acceptance_extras (val , validator_extras ):
65
+ assert validator_extras .validate_coerce (val ) == val
66
+
67
+ # Test rejection by extras
68
+ @pytest .mark .parametrize ("val" , ['italic' , 'bolditalic' ])
69
+ def test_rejection_extras (val , validator_extras ):
70
+ with pytest .raises (ValueError ) as validation_failure :
71
+ validator_extras .validate_coerce (val )
72
+
73
+ assert "Invalid value" in str (validation_failure .value )
59
74
60
75
@pytest .mark .parametrize (
61
76
"val" , [- 1.01 , - 10 , 2.1 , 3 , np .iinfo (int ).max , np .iinfo (int ).min ]
0 commit comments