1
1
import nose
2
-
2
+ from distutils . version import LooseVersion
3
3
import numpy as np
4
4
5
5
from pandas import tslib
@@ -137,13 +137,24 @@ def test_constructor_with_stringoffset(self):
137
137
self .assertEqual (result , eval (repr (result )))
138
138
139
139
def test_repr (self ):
140
+ tm ._skip_if_no_pytz ()
141
+ tm ._skip_if_no_dateutil ()
142
+
140
143
dates = ['2014-03-07' , '2014-01-01 09:00' , '2014-01-01 00:00:00.000000001' ]
141
- timezones = ['UTC' , 'Asia/Tokyo' , 'US/Eastern' , 'dateutil/America/Los_Angeles' ]
144
+
145
+ # dateutil zone change (only matters for repr)
146
+ import dateutil
147
+ if dateutil .__version__ >= LooseVersion ('2.3' ):
148
+ timezones = ['UTC' , 'Asia/Tokyo' , 'US/Eastern' , 'dateutil/US/Pacific' ]
149
+ else :
150
+ timezones = ['UTC' , 'Asia/Tokyo' , 'US/Eastern' , 'dateutil/America/Los_Angeles' ]
151
+
142
152
freqs = ['D' , 'M' , 'S' , 'N' ]
143
153
144
154
for date in dates :
145
155
for tz in timezones :
146
156
for freq in freqs :
157
+
147
158
# avoid to match with timezone name
148
159
freq_repr = "'{0}'" .format (freq )
149
160
if tz .startswith ('dateutil' ):
@@ -306,10 +317,10 @@ def test_now(self):
306
317
ts_from_string = Timestamp ('now' )
307
318
ts_from_method = Timestamp .now ()
308
319
ts_datetime = datetime .datetime .now ()
309
-
320
+
310
321
ts_from_string_tz = Timestamp ('now' , tz = 'US/Eastern' )
311
322
ts_from_method_tz = Timestamp .now (tz = 'US/Eastern' )
312
-
323
+
313
324
# Check that the delta between the times is less than 1s (arbitrarily small)
314
325
delta = Timedelta (seconds = 1 )
315
326
self .assertTrue ((ts_from_method - ts_from_string ) < delta )
@@ -321,10 +332,10 @@ def test_today(self):
321
332
ts_from_string = Timestamp ('today' )
322
333
ts_from_method = Timestamp .today ()
323
334
ts_datetime = datetime .datetime .today ()
324
-
335
+
325
336
ts_from_string_tz = Timestamp ('today' , tz = 'US/Eastern' )
326
337
ts_from_method_tz = Timestamp .today (tz = 'US/Eastern' )
327
-
338
+
328
339
# Check that the delta between the times is less than 1s (arbitrarily small)
329
340
delta = Timedelta (seconds = 1 )
330
341
self .assertTrue ((ts_from_method - ts_from_string ) < delta )
@@ -737,7 +748,7 @@ def test_resolution(self):
737
748
for freq , expected in zip (['A' , 'Q' , 'M' , 'D' , 'H' , 'T' , 'S' , 'L' , 'U' ],
738
749
[tslib .D_RESO , tslib .D_RESO , tslib .D_RESO , tslib .D_RESO ,
739
750
tslib .H_RESO , tslib .T_RESO ,tslib .S_RESO , tslib .MS_RESO , tslib .US_RESO ]):
740
- for tz in [None , 'Asia/Tokyo' , 'US/Eastern' ]:
751
+ for tz in [None , 'Asia/Tokyo' , 'US/Eastern' , 'dateutil/US/Eastern' ]:
741
752
idx = date_range (start = '2013-04-01' , periods = 30 , freq = freq , tz = tz )
742
753
result = tslib .resolution (idx .asi8 , idx .tz )
743
754
self .assertEqual (result , expected )
0 commit comments