@@ -955,7 +955,12 @@ def test_dt64arr_add_sub_td64ndarray(self, tz_naive_fixture, box_with_array):
955955
956956 result = dtarr - tdarr
957957 tm .assert_equal (result , expected )
958- msg = "cannot subtract|(bad|unsupported) operand type for unary"
958+ msg = "|" .join (
959+ [
960+ "cannot subtract DatetimeArray from ndarray" ,
961+ "cannot subtract a datelike from a TimedeltaArray" ,
962+ ]
963+ )
959964 with pytest .raises (TypeError , match = msg ):
960965 tdarr - dtarr
961966
@@ -1272,7 +1277,7 @@ def test_dt64arr_series_sub_tick_DateOffset(self, box_with_array):
12721277
12731278 result2 = - pd .offsets .Second (5 ) + ser
12741279 tm .assert_equal (result2 , expected )
1275- msg = "(bad|unsupported) operand type for unary "
1280+ msg = "cannot subtract DatetimeArray from Second "
12761281 with pytest .raises (TypeError , match = msg ):
12771282 pd .offsets .Second (5 ) - ser
12781283
@@ -1317,9 +1322,7 @@ def test_dti_add_tick_tzaware(self, tz_aware_fixture, box_with_array):
13171322 roundtrip = offset - scalar
13181323 tm .assert_equal (roundtrip , dates )
13191324
1320- msg = "|" .join (
1321- ["bad operand type for unary -" , "cannot subtract DatetimeArray" ]
1322- )
1325+ msg = "cannot subtract DatetimeArray from"
13231326 with pytest .raises (TypeError , match = msg ):
13241327 scalar - dates
13251328
@@ -1378,7 +1381,7 @@ def test_dt64arr_add_sub_relativedelta_offsets(self, box_with_array, unit):
13781381 expected = DatetimeIndex ([x - off for x in vec_items ]).as_unit (exp_unit )
13791382 expected = tm .box_expected (expected , box_with_array )
13801383 tm .assert_equal (expected , vec - off )
1381- msg = "(bad|unsupported) operand type for unary "
1384+ msg = "cannot subtract DatetimeArray from "
13821385 with pytest .raises (TypeError , match = msg ):
13831386 off - vec
13841387
@@ -1494,7 +1497,7 @@ def test_dt64arr_add_sub_DateOffsets(
14941497 expected = DatetimeIndex ([offset + x for x in vec_items ]).as_unit (unit )
14951498 expected = tm .box_expected (expected , box_with_array )
14961499 tm .assert_equal (expected , offset + vec )
1497- msg = "(bad|unsupported) operand type for unary "
1500+ msg = "cannot subtract DatetimeArray from "
14981501 with pytest .raises (TypeError , match = msg ):
14991502 offset - vec
15001503
@@ -1983,7 +1986,7 @@ def test_operators_datetimelike_with_timezones(self):
19831986 result = dt1 - td1 [0 ]
19841987 exp = (dt1 .dt .tz_localize (None ) - td1 [0 ]).dt .tz_localize (tz )
19851988 tm .assert_series_equal (result , exp )
1986- msg = "(bad|unsupported) operand type for unary "
1989+ msg = "cannot subtract DatetimeArray from "
19871990 with pytest .raises (TypeError , match = msg ):
19881991 td1 [0 ] - dt1
19891992
0 commit comments