@@ -212,17 +212,13 @@ def test_td_constructor_value_error():
212
212
Timedelta (nanoseconds = 'abc' )
213
213
214
214
215
- @pytest .mark .parametrize ("redundant_unit, expectation" , [
216
- ("" , tm .do_not_raise ),
217
- ("d" , pytest .raises (ValueError )),
218
- ("us" , pytest .raises (ValueError ))])
219
- @pytest .mark .parametrize ("unit" , [
220
- "d" , "m" , "s" , "us" ])
221
- @pytest .mark .parametrize ("sign" , [
222
- + 1 , - 1 ])
223
- @pytest .mark .parametrize ("num" , [
224
- 0.001 , 1 , 10 ])
225
- def test_string_with_unit (num , sign , unit , redundant_unit , expectation ):
215
+ @pytest .mark .parametrize ("str_unit, unit, expectation" , [
216
+ ("" , "s" , tm .do_not_raise ),
217
+ ("s" , "s" , pytest .raises (ValueError )),
218
+ ("" , None , pytest .raises (ValueError )),
219
+ ("s" , "d" , pytest .raises (ValueError )),])
220
+ def test_string_with_unit (str_unit , unit , expectation ):
226
221
with expectation :
227
- assert Timedelta (str (sign * num ) + redundant_unit , unit = unit ) \
228
- == Timedelta (sign * num , unit = unit )
222
+ val_str = "10{}" .format (str_unit )
223
+ assert Timedelta (val_str , unit = unit ) == Timedelta (10 , unit = unit )
224
+ assert pd .to_timedelta (val_str , unit = unit ) == Timedelta (10 , unit = unit )
0 commit comments