@@ -171,24 +171,44 @@ def test_decimal_kwargs(py_and_json: PyAndJson, kwargs: dict[str, Any], input_va
171
171
@pytest .mark .parametrize (
172
172
'multiple_of,input_value,error' ,
173
173
[
174
- (0.5 , 0.5 , None ),
175
- (0.5 , 1 , None ),
174
+ # Test cases for multiples of 0.5
175
+ * [(0.5 , round (i * 0.5 , 1 ), None ) for i in range (- 4 , 5 )],
176
+ (0.5 , 0.49 , Err ('Input should be a multiple of 0.5' )),
176
177
(0.5 , 0.6 , Err ('Input should be a multiple of 0.5' )),
177
- (0.5 , 0.51 , Err ('Input should be a multiple of 0.5' )),
178
+ (0.5 , - 0.75 , Err ('Input should be a multiple of 0.5' )),
178
179
(0.5 , 0.501 , Err ('Input should be a multiple of 0.5' )),
179
180
(0.5 , 1_000_000.5 , None ),
180
181
(0.5 , 1_000_000.49 , Err ('Input should be a multiple of 0.5' )),
182
+ (0.5 , int (5e10 ), None ),
183
+ # Test cases for multiples of 0.1
184
+ * [(0.1 , round (i * 0.1 , 1 ), None ) for i in range (- 10 , 11 )],
181
185
(0.1 , 0 , None ),
182
- (0.1 , 0.0 , None ),
183
- (0.1 , 0.2 , None ),
184
- (0.1 , 0.3 , None ),
185
- (0.1 , 0.4 , None ),
186
- (0.1 , 0.5 , None ),
187
186
(0.1 , 0.5001 , Err ('Input should be a multiple of 0.1' )),
187
+ (0.1 , 0.05 , Err ('Input should be a multiple of 0.1' )),
188
+ (0.1 , - 0.15 , Err ('Input should be a multiple of 0.1' )),
189
+ (0.1 , 1_000_000.1 , None ),
190
+ (0.1 , 1_000_000.05 , Err ('Input should be a multiple of 0.1' )),
188
191
(0.1 , 1 , None ),
189
- (0.1 , 1.0 , None ),
190
192
(0.1 , int (5e10 ), None ),
191
- (2.0 , - 2.0 , None ),
193
+ # Test cases for multiples of 2.0
194
+ * [(2.0 , i * 2.0 , None ) for i in range (- 5 , 6 )],
195
+ (2.0 , - 2.1 , Err ('Input should be a multiple of 2' )),
196
+ (2.0 , - 3.0 , Err ('Input should be a multiple of 2' )),
197
+ (2.0 , 1_000_002.0 , None ),
198
+ (2.0 , 1_000_001.0 , Err ('Input should be a multiple of 2' )),
199
+ (2.0 , int (5e10 ), None ),
200
+ # Test cases for multiples of 0.01
201
+ * [(0.01 , round (i * 0.01 , 2 ), None ) for i in range (- 10 , 11 )],
202
+ (0.01 , 0.005 , Err ('Input should be a multiple of 0.01' )),
203
+ (0.01 , - 0.015 , Err ('Input should be a multiple of 0.01' )),
204
+ (0.01 , 1_000_000.01 , None ),
205
+ (0.01 , 1_000_000.005 , Err ('Input should be a multiple of 0.01' )),
206
+ (0.01 , int (5e10 ), None ),
207
+ # Test cases for values very close to zero
208
+ (0.1 , 0.00001 , Err ('Input should be a multiple of 0.1' )),
209
+ (0.1 , - 0.00001 , Err ('Input should be a multiple of 0.1' )),
210
+ (0.01 , 0.00001 , Err ('Input should be a multiple of 0.01' )),
211
+ (0.01 , - 0.00001 , Err ('Input should be a multiple of 0.01' )),
192
212
],
193
213
ids = repr ,
194
214
)
0 commit comments