Skip to content

Commit 8f7430f

Browse files
committed
replace prev error msg to new implemented error msg
1 parent 5feb3a6 commit 8f7430f

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

pandas/tests/arithmetic/test_datetime64.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
starmap,
1313
)
1414
import operator
15+
import re
1516

1617
import numpy as np
1718
import pytest
18-
import re
1919

2020
from pandas._libs.tslibs.conversion import localize_pydatetime
2121
from pandas._libs.tslibs.offsets import shift_months
@@ -1321,8 +1321,12 @@ def test_dti_add_tick_tzaware(self, tz_aware_fixture, box_with_array):
13211321
roundtrip = offset - scalar
13221322
tm.assert_equal(roundtrip, dates)
13231323

1324-
msg = f"TypeError: unsupported operand type(s) for -: 'DatetimeArray' and '{type(scalar).__name__}'"
1325-
with pytest.raises(TypeError, match=re.escape(msg)):
1324+
msg = (
1325+
r"TypeError: unsupported operand type\(s\) "
1326+
"for -: 'DatetimeArray' and '.*'|"
1327+
r"cannot subtract DatetimeArray from .*"
1328+
)
1329+
with pytest.raises(TypeError, match=msg):
13261330
scalar - dates
13271331

13281332
# -------------------------------------------------------------
@@ -1380,7 +1384,10 @@ def test_dt64arr_add_sub_relativedelta_offsets(self, box_with_array, unit):
13801384
expected = DatetimeIndex([x - off for x in vec_items]).as_unit(exp_unit)
13811385
expected = tm.box_expected(expected, box_with_array)
13821386
tm.assert_equal(expected, vec - off)
1383-
msg = "(bad|unsupported) operand type for unary"
1387+
msg = (
1388+
r"TypeError: unsupported operand type\(s\) "
1389+
"for -: 'DatetimeArray' and '.*'"
1390+
)
13841391
with pytest.raises(TypeError, match=msg):
13851392
off - vec
13861393

@@ -1496,7 +1503,9 @@ def test_dt64arr_add_sub_DateOffsets(
14961503
expected = DatetimeIndex([offset + x for x in vec_items]).as_unit(unit)
14971504
expected = tm.box_expected(expected, box_with_array)
14981505
tm.assert_equal(expected, offset + vec)
1499-
msg = "(bad|unsupported) operand type for unary"
1506+
msg = (
1507+
r"TypeError: unsupported operand type\(s\) for -: 'DatetimeArray' and '.*'"
1508+
)
15001509
with pytest.raises(TypeError, match=msg):
15011510
offset - vec
15021511

@@ -1985,7 +1994,9 @@ def test_operators_datetimelike_with_timezones(self):
19851994
result = dt1 - td1[0]
19861995
exp = (dt1.dt.tz_localize(None) - td1[0]).dt.tz_localize(tz)
19871996
tm.assert_series_equal(result, exp)
1988-
msg = "(bad|unsupported) operand type for unary"
1997+
msg = (
1998+
r"TypeError: unsupported operand type\(s\) for -: 'DatetimeArray' and '.*'"
1999+
)
19892000
with pytest.raises(TypeError, match=msg):
19902001
td1[0] - dt1
19912002

0 commit comments

Comments
 (0)