@@ -787,6 +787,65 @@ def test_construction_with_nat_and_tzlocal(self):
787787 expected = DatetimeIndex ([Timestamp ("2018" , tz = tz ), pd .NaT ])
788788 tm .assert_index_equal (result , expected )
789789
790+ def test_constructor_with_ambiguous_keyword_arg (self ):
791+ # GH 35297
792+
793+ expected = DatetimeIndex (
794+ ["2020-11-01 01:00:00" , "2020-11-02 01:00:00" ],
795+ dtype = "datetime64[ns, America/New_York]" ,
796+ freq = "D" ,
797+ ambiguous = False ,
798+ )
799+
800+ # ambiguous keyword in start
801+ timezone = "America/New_York"
802+ start = pd .Timestamp (year = 2020 , month = 11 , day = 1 , hour = 1 ).tz_localize (
803+ timezone , ambiguous = False
804+ )
805+ result = pd .date_range (start = start , periods = 2 , ambiguous = False )
806+ tm .assert_index_equal (result , expected )
807+
808+ # ambiguous keyword in end
809+ timezone = "America/New_York"
810+ end = pd .Timestamp (year = 2020 , month = 11 , day = 2 , hour = 1 ).tz_localize (
811+ timezone , ambiguous = False
812+ )
813+ result = pd .date_range (end = end , periods = 2 , ambiguous = False )
814+ tm .assert_index_equal (result , expected )
815+
816+ def test_constructor_with_nonexistent_keyword_arg (self ):
817+ # GH 35297
818+
819+ timezone = "Europe/Warsaw"
820+
821+ # nonexistent keyword in start
822+ start = pd .Timestamp ("2015-03-29 02:30:00" ).tz_localize (
823+ timezone , nonexistent = "shift_forward"
824+ )
825+ result = pd .date_range (start = start , periods = 2 , freq = "H" )
826+ expected = DatetimeIndex (
827+ [
828+ pd .Timestamp ("2015-03-29 03:00:00+02:00" , tz = timezone ),
829+ pd .Timestamp ("2015-03-29 04:00:00+02:00" , tz = timezone ),
830+ ]
831+ )
832+
833+ tm .assert_index_equal (result , expected )
834+
835+ # nonexistent keyword in end
836+ end = pd .Timestamp ("2015-03-29 02:30:00" ).tz_localize (
837+ timezone , nonexistent = "shift_forward"
838+ )
839+ result = pd .date_range (end = end , periods = 2 , freq = "H" )
840+ expected = DatetimeIndex (
841+ [
842+ pd .Timestamp ("2015-03-29 01:00:00+01:00" , tz = timezone ),
843+ pd .Timestamp ("2015-03-29 03:00:00+02:00" , tz = timezone ),
844+ ]
845+ )
846+
847+ tm .assert_index_equal (result , expected )
848+
790849 def test_constructor_no_precision_raises (self ):
791850 # GH-24753, GH-24739
792851
0 commit comments