@@ -27,8 +27,12 @@ def validator_strict():
27
27
28
28
@pytest .fixture
29
29
def validator_aok ():
30
- return StringValidator ('prop' , 'parent' , array_ok = True , strict = True )
30
+ return StringValidator ('prop' , 'parent' , array_ok = True , strict = False )
31
+
31
32
33
+ @pytest .fixture
34
+ def validator_aok_strict ():
35
+ return StringValidator ('prop' , 'parent' , array_ok = True , strict = True )
32
36
33
37
@pytest .fixture
34
38
def validator_aok_values ():
@@ -127,7 +131,8 @@ def test_acceptance_aok_scalars(val, validator_aok):
127
131
['foo' ,
128
132
['foo' ],
129
133
np .array (['BAR' , '' ], dtype = 'object' ),
130
- ['baz' , 'baz' , 'baz' ]])
134
+ ['baz' , 'baz' , 'baz' ],
135
+ ['foo' , None , 'bar' ]])
131
136
def test_acceptance_aok_list (val , validator_aok ):
132
137
coerce_val = validator_aok .validate_coerce (val )
133
138
if isinstance (val , np .ndarray ):
@@ -143,16 +148,19 @@ def test_acceptance_aok_list(val, validator_aok):
143
148
# ### Rejection by type ###
144
149
@pytest .mark .parametrize ('val' ,
145
150
[['foo' , ()], ['foo' , 3 , 4 ], [3 , 2 , 1 ]])
146
- def test_rejection_aok (val , validator_aok ):
151
+ def test_rejection_aok (val , validator_aok_strict ):
147
152
with pytest .raises (ValueError ) as validation_failure :
148
- validator_aok .validate_coerce (val )
153
+ validator_aok_strict .validate_coerce (val )
149
154
150
155
assert 'Invalid element(s)' in str (validation_failure .value )
151
156
152
157
153
158
# ### Rejection by value ###
154
159
@pytest .mark .parametrize ('val' ,
155
- [['foo' , 'bar' ], ['3' , '4' ], ['BAR' , 'BAR' , 'hello!' ]])
160
+ [['foo' , 'bar' ],
161
+ ['3' , '4' ],
162
+ ['BAR' , 'BAR' , 'hello!' ],
163
+ ['foo' , None ]])
156
164
def test_rejection_aok_values (val , validator_aok_values ):
157
165
with pytest .raises (ValueError ) as validation_failure :
158
166
validator_aok_values .validate_coerce (val )
0 commit comments