@@ -85,6 +85,10 @@ def test_construction():
85
85
with pytest .raises (ValueError ):
86
86
Timedelta ('10 days -1 h 1.5m 1s 3us' )
87
87
88
+ # no units specified
89
+ with pytest .raises (ValueError ):
90
+ Timedelta ('3.1415' )
91
+
88
92
# invalid construction
89
93
tm .assert_raises_regex (ValueError , "cannot construct a Timedelta" ,
90
94
lambda : Timedelta ())
@@ -219,15 +223,17 @@ def __exit__(self, exc_type, exc_val, exc_tb):
219
223
@pytest .mark .parametrize ("redundant_unit, expectation" , [
220
224
("" , not_raises ()),
221
225
("d" , pytest .raises (ValueError )),
222
- ("us" , pytest .raises (ValueError ))])
226
+ ("us" , pytest .raises (ValueError )),
227
+ ])
223
228
@pytest .mark .parametrize ("unit" , [
224
- "d" , "m" , "s" , "us" ])
229
+ "d" , "m" , "s" , "us"
230
+ ])
225
231
@pytest .mark .parametrize ("sign" , [
226
- + 1 , - 1 ])
232
+ + 1 , - 1
233
+ ])
227
234
@pytest .mark .parametrize ("num" , [
228
- 0.001 , 1 , 10 ])
235
+ 0.001 , 1 , 10
236
+ ])
229
237
def test_string_with_unit (num , sign , unit , redundant_unit , expectation ):
230
238
with expectation :
231
- val = sign * num
232
- val_str = str (val ) + redundant_unit
233
- assert Timedelta (val_str , unit = unit ) == Timedelta (val , unit = unit )
239
+ assert Timedelta (str (sign * num )+ redundant_unit , unit = unit ) == Timedelta (sign * num , unit = unit )
0 commit comments