Skip to content

Commit 1df1edc

Browse files
committed
modify tests revolving this issue
1 parent 9f14a2a commit 1df1edc

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

pandas/tests/arithmetic/test_datetime64.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import numpy as np
1717
import pytest
18+
import re
1819

1920
from pandas._libs.tslibs.conversion import localize_pydatetime
2021
from pandas._libs.tslibs.offsets import shift_months
@@ -1273,8 +1274,10 @@ def test_dt64arr_series_sub_tick_DateOffset(self, box_with_array):
12731274

12741275
result2 = -pd.offsets.Second(5) + ser
12751276
tm.assert_equal(result2, expected)
1276-
msg = "(bad|unsupported) operand type for unary"
1277-
with pytest.raises(TypeError, match=msg):
1277+
msg = (
1278+
"TypeError: unsupported operand type(s) for -: 'DatetimeArray' and 'Second'"
1279+
)
1280+
with pytest.raises(TypeError, match=re.escape(msg)):
12781281
pd.offsets.Second(5) - ser
12791282

12801283
@pytest.mark.parametrize(
@@ -1318,10 +1321,8 @@ def test_dti_add_tick_tzaware(self, tz_aware_fixture, box_with_array):
13181321
roundtrip = offset - scalar
13191322
tm.assert_equal(roundtrip, dates)
13201323

1321-
msg = "|".join(
1322-
["bad operand type for unary -", "cannot subtract DatetimeArray"]
1323-
)
1324-
with pytest.raises(TypeError, match=msg):
1324+
msg = f"TypeError: unsupported operand type(s) for -: 'DatetimeArray' and '{type(scalar).__name__}'"
1325+
with pytest.raises(TypeError, match=re.escape(msg)):
13251326
scalar - dates
13261327

13271328
# -------------------------------------------------------------

0 commit comments

Comments
 (0)