@@ -774,18 +774,15 @@ def test_construction_with_nat_and_tzlocal(self):
774
774
expected = DatetimeIndex ([Timestamp ("2018" , tz = tz ), pd .NaT ])
775
775
tm .assert_index_equal (result , expected )
776
776
777
- def test_constructor_no_precision_warns (self ):
777
+ def test_constructor_no_precision_raises (self ):
778
778
# GH-24753, GH-24739
779
- expected = pd .DatetimeIndex (["2000" ], dtype = "datetime64[ns]" )
780
779
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" )
785
783
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" )
789
786
790
787
def test_constructor_wrong_precision_raises (self ):
791
788
with pytest .raises (ValueError ):
0 commit comments