@@ -204,15 +204,26 @@ def test_overflow_on_construction():
204
204
Timedelta (timedelta (days = 13 * 19999 ))
205
205
206
206
207
- def test_construction_out_of_bounds_td64 ():
207
+ @pytest .mark .parametrize (
208
+ "val, unit, name" ,
209
+ [
210
+ (3508 , "M" , " months" ),
211
+ (15251 , "W" , " weeks" ), # 1
212
+ (106752 , "D" , " days" ), # change from previous:
213
+ (2562048 , "h" , " hours" ), # 0 hours
214
+ (153722868 , "m" , " minutes" ), # 13 minutes
215
+ (9223372037 , "s" , " seconds" ), # 44 seconds
216
+ ],
217
+ )
218
+ def test_construction_out_of_bounds_td64 (val , unit , name ):
208
219
# TODO: parametrize over units just above/below the implementation bounds
209
220
# once GH#38964 is resolved
210
221
211
222
# Timedelta.max is just under 106752 days
212
- td64 = np .timedelta64 (106752 , "D" )
223
+ td64 = np .timedelta64 (val , unit )
213
224
assert td64 .astype ("m8[ns]" ).view ("i8" ) < 0 # i.e. naive astype will be wrong
214
225
215
- msg = "106752 days"
226
+ msg = str ( val ) + name
216
227
with pytest .raises (OutOfBoundsTimedelta , match = msg ):
217
228
Timedelta (td64 )
218
229
@@ -222,7 +233,7 @@ def test_construction_out_of_bounds_td64():
222
233
td64 *= - 1
223
234
assert td64 .astype ("m8[ns]" ).view ("i8" ) > 0 # i.e. naive astype will be wrong
224
235
225
- with pytest .raises (OutOfBoundsTimedelta , match = msg ):
236
+ with pytest .raises (OutOfBoundsTimedelta , match = "-" + msg ):
226
237
Timedelta (td64 )
227
238
228
239
# But just back in bounds and we are OK
0 commit comments