@@ -32,6 +32,9 @@ def validator_max():
3232def validator_aok (request ):
3333 return IntegerValidator ("prop" , "parent" , min = - 2 , max = 10 , array_ok = True )
3434
35+ @pytest .fixture
36+ def validator_extras ():
37+ return IntegerValidator ("prop" , "parent" , extras = ['normal' , 'bold' ])
3538
3639# ### Acceptance ###
3740@pytest .mark .parametrize ("val" , [1 , - 19 , 0 , - 1234 ])
@@ -56,6 +59,18 @@ def test_rejection_by_value(val, validator):
5659def test_acceptance_min_max (val , validator_min_max ):
5760 assert validator_min_max .validate_coerce (val ) == approx (val )
5861
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 )
5974
6075@pytest .mark .parametrize (
6176 "val" , [- 1.01 , - 10 , 2.1 , 3 , np .iinfo (int ).max , np .iinfo (int ).min ]
0 commit comments