@@ -774,18 +774,15 @@ def test_construction_with_nat_and_tzlocal(self):
774774 expected = DatetimeIndex ([Timestamp ("2018" , tz = tz ), pd .NaT ])
775775 tm .assert_index_equal (result , expected )
776776
777- def test_constructor_no_precision_warns (self ):
777+ def test_constructor_no_precision_raises (self ):
778778 # GH-24753, GH-24739
779- expected = pd .DatetimeIndex (["2000" ], dtype = "datetime64[ns]" )
780779
781- # we set the stacklevel for DatetimeIndex
782- with tm .assert_produces_warning (FutureWarning ):
783- result = pd .DatetimeIndex (["2000" ], dtype = "datetime64" )
784- tm .assert_index_equal (result , expected )
780+ msg = "with no precision is not allowed"
781+ with pytest .raises (ValueError , match = msg ):
782+ pd .DatetimeIndex (["2000" ], dtype = "datetime64" )
785783
786- with tm .assert_produces_warning (FutureWarning , check_stacklevel = False ):
787- result = pd .Index (["2000" ], dtype = "datetime64" )
788- tm .assert_index_equal (result , expected )
784+ with pytest .raises (ValueError , match = msg ):
785+ pd .Index (["2000" ], dtype = "datetime64" )
789786
790787 def test_constructor_wrong_precision_raises (self ):
791788 with pytest .raises (ValueError ):
0 commit comments