@@ -354,25 +354,51 @@ def test_range_bug(self):
354354 def test_range_tz_pytz (self ):
355355 # GH 2906
356356 tm ._skip_if_no_pytz ()
357- from pytz import timezone as tz
357+ from pytz import timezone
358358
359- start = datetime (2011 , 1 , 1 , tzinfo = tz ('US/Eastern' ))
360- end = datetime (2011 , 1 , 3 , tzinfo = tz ('US/Eastern' ))
359+ tz = timezone ('US/Eastern' )
360+ start = tz .localize (datetime (2011 , 1 , 1 ))
361+ end = tz .localize (datetime (2011 , 1 , 3 ))
361362
362363 dr = date_range (start = start , periods = 3 )
363- self .assertEqual (dr .tz , tz ( 'US/Eastern' ) )
364+ self .assertEqual (dr .tz . zone , tz . zone )
364365 self .assertEqual (dr [0 ], start )
365366 self .assertEqual (dr [2 ], end )
366367
367368 dr = date_range (end = end , periods = 3 )
368- self .assertEqual (dr .tz , tz ( 'US/Eastern' ) )
369+ self .assertEqual (dr .tz . zone , tz . zone )
369370 self .assertEqual (dr [0 ], start )
370371 self .assertEqual (dr [2 ], end )
371372
372373 dr = date_range (start = start , end = end )
373- self .assertEqual (dr .tz , tz ( 'US/Eastern' ) )
374+ self .assertEqual (dr .tz . zone , tz . zone )
374375 self .assertEqual (dr [0 ], start )
375376 self .assertEqual (dr [2 ], end )
377+
378+ def test_range_tz_dst_straddle_pytz (self ):
379+
380+ tm ._skip_if_no_pytz ()
381+ from pytz import timezone
382+ tz = timezone ('US/Eastern' )
383+ dates = [(tz .localize (datetime (2014 , 3 , 6 )),
384+ tz .localize (datetime (2014 , 3 , 12 ))),
385+ (tz .localize (datetime (2013 , 11 , 1 )),
386+ tz .localize (datetime (2013 , 11 , 6 )))]
387+ for (start , end ) in dates :
388+ dr = date_range (start , end , freq = 'D' )
389+ self .assertEqual (dr [0 ], start )
390+ self .assertEqual (dr [- 1 ], end )
391+ self .assertEqual (np .all (dr .hour == 0 ), True )
392+
393+ dr = date_range (start , end , freq = 'D' , tz = 'US/Eastern' )
394+ self .assertEqual (dr [0 ], start )
395+ self .assertEqual (dr [- 1 ], end )
396+ self .assertEqual (np .all (dr .hour == 0 ), True )
397+
398+ dr = date_range (start .replace (tzinfo = None ), end .replace (tzinfo = None ), freq = 'D' , tz = 'US/Eastern' )
399+ self .assertEqual (dr [0 ], start )
400+ self .assertEqual (dr [- 1 ], end )
401+ self .assertEqual (np .all (dr .hour == 0 ), True )
376402
377403 def test_range_tz_dateutil (self ):
378404 # GH 2906
0 commit comments