11import nose
2-
2+ from distutils . version import LooseVersion
33import numpy as np
44
55from pandas import tslib
@@ -137,13 +137,24 @@ def test_constructor_with_stringoffset(self):
137137 self .assertEqual (result , eval (repr (result )))
138138
139139 def test_repr (self ):
140+ tm ._skip_if_no_pytz ()
141+ tm ._skip_if_no_dateutil ()
142+
140143 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+
142152 freqs = ['D' , 'M' , 'S' , 'N' ]
143153
144154 for date in dates :
145155 for tz in timezones :
146156 for freq in freqs :
157+
147158 # avoid to match with timezone name
148159 freq_repr = "'{0}'" .format (freq )
149160 if tz .startswith ('dateutil' ):
@@ -306,10 +317,10 @@ def test_now(self):
306317 ts_from_string = Timestamp ('now' )
307318 ts_from_method = Timestamp .now ()
308319 ts_datetime = datetime .datetime .now ()
309-
320+
310321 ts_from_string_tz = Timestamp ('now' , tz = 'US/Eastern' )
311322 ts_from_method_tz = Timestamp .now (tz = 'US/Eastern' )
312-
323+
313324 # Check that the delta between the times is less than 1s (arbitrarily small)
314325 delta = Timedelta (seconds = 1 )
315326 self .assertTrue ((ts_from_method - ts_from_string ) < delta )
@@ -321,10 +332,10 @@ def test_today(self):
321332 ts_from_string = Timestamp ('today' )
322333 ts_from_method = Timestamp .today ()
323334 ts_datetime = datetime .datetime .today ()
324-
335+
325336 ts_from_string_tz = Timestamp ('today' , tz = 'US/Eastern' )
326337 ts_from_method_tz = Timestamp .today (tz = 'US/Eastern' )
327-
338+
328339 # Check that the delta between the times is less than 1s (arbitrarily small)
329340 delta = Timedelta (seconds = 1 )
330341 self .assertTrue ((ts_from_method - ts_from_string ) < delta )
@@ -737,7 +748,7 @@ def test_resolution(self):
737748 for freq , expected in zip (['A' , 'Q' , 'M' , 'D' , 'H' , 'T' , 'S' , 'L' , 'U' ],
738749 [tslib .D_RESO , tslib .D_RESO , tslib .D_RESO , tslib .D_RESO ,
739750 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' ]:
741752 idx = date_range (start = '2013-04-01' , periods = 30 , freq = freq , tz = tz )
742753 result = tslib .resolution (idx .asi8 , idx .tz )
743754 self .assertEqual (result , expected )
0 commit comments