@@ -32,13 +32,18 @@ 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
+
35
36
@pytest .fixture
36
37
def 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
+
38
40
39
41
@pytest .fixture
40
42
def 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
+
42
47
43
48
# ### Acceptance ###
44
49
@pytest .mark .parametrize ("val" , [1 , - 19 , 0 , - 1234 ])
@@ -63,24 +68,28 @@ def test_rejection_by_value(val, validator):
63
68
def test_acceptance_min_max (val , validator_min_max ):
64
69
assert validator_min_max .validate_coerce (val ) == approx (val )
65
70
71
+
66
72
# With extras
67
- @pytest .mark .parametrize ("val" , [' normal' , ' bold' , 10 , - 2 ])
73
+ @pytest .mark .parametrize ("val" , [" normal" , " bold" , 10 , - 2 ])
68
74
def test_acceptance_extras (val , validator_extras ):
69
75
assert validator_extras .validate_coerce (val ) == val
70
76
77
+
71
78
# 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 ]])
73
80
def test_acceptance_extras_array (val , validator_extras_aok ):
74
81
assert validator_extras_aok .validate_coerce (val ) == val
75
82
83
+
76
84
# 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 ])
78
86
def test_rejection_extras (val , validator_extras ):
79
87
with pytest .raises (ValueError ) as validation_failure :
80
88
validator_extras .validate_coerce (val )
81
89
82
90
assert "Invalid value" in str (validation_failure .value )
83
91
92
+
84
93
@pytest .mark .parametrize (
85
94
"val" , [- 1.01 , - 10 , 2.1 , 3 , np .iinfo (int ).max , np .iinfo (int ).min ]
86
95
)
0 commit comments