@@ -1753,16 +1753,15 @@ def test_date_range_tzaware_endpoints_accept_ambiguous(self):
17531753
17541754 def test_date_range_tzaware_endpoints_accept_nonexistent (self ):
17551755 # Europe/London spring-forward: 2015-03-29 01:30 does not exist.
1756- start = Timestamp ("2015-03-28 01:30" , tz = "Europe/London" )
1757- end = Timestamp ("2015-03-30 01:30" , tz = "Europe/London" )
1756+ tz = "Europe/London"
1757+ start = Timestamp ("2015-03-28 01:30" , tz = tz )
1758+ end = Timestamp ("2015-03-30 01:30" , tz = tz )
17581759
17591760 result = date_range (start , end , freq = "D" , nonexistent = "shift_forward" )
1760- expected = [
1761- Timestamp ("2015-03-28 01:30:00+00:00" ),
1762- Timestamp (
1763- "2015-03-29 02:00:00+01:00"
1764- ), # shifted forward over next valid wall time
1765- Timestamp ("2015-03-30 01:30:00+01:00" ),
1766- ]
17671761
1768- assert list (result ) == expected
1762+ # Build expected by generating naive daily times, then tz_localize so
1763+ # the nonexistent handling is applied during localization.
1764+ expected = date_range (
1765+ "2015-03-28 01:30" , "2015-03-30 01:30" , freq = "D"
1766+ ).tz_localize (tz , nonexistent = "shift_forward" )
1767+ tm .assert_index_equal (result , expected )
0 commit comments