|
12 | 12 | starmap, |
13 | 13 | ) |
14 | 14 | import operator |
| 15 | +import re |
15 | 16 |
|
16 | 17 | import numpy as np |
17 | 18 | import pytest |
18 | | -import re |
19 | 19 |
|
20 | 20 | from pandas._libs.tslibs.conversion import localize_pydatetime |
21 | 21 | 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): |
1321 | 1321 | roundtrip = offset - scalar |
1322 | 1322 | tm.assert_equal(roundtrip, dates) |
1323 | 1323 |
|
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): |
1326 | 1330 | scalar - dates |
1327 | 1331 |
|
1328 | 1332 | # ------------------------------------------------------------- |
@@ -1380,7 +1384,10 @@ def test_dt64arr_add_sub_relativedelta_offsets(self, box_with_array, unit): |
1380 | 1384 | expected = DatetimeIndex([x - off for x in vec_items]).as_unit(exp_unit) |
1381 | 1385 | expected = tm.box_expected(expected, box_with_array) |
1382 | 1386 | 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 | + ) |
1384 | 1391 | with pytest.raises(TypeError, match=msg): |
1385 | 1392 | off - vec |
1386 | 1393 |
|
@@ -1496,7 +1503,9 @@ def test_dt64arr_add_sub_DateOffsets( |
1496 | 1503 | expected = DatetimeIndex([offset + x for x in vec_items]).as_unit(unit) |
1497 | 1504 | expected = tm.box_expected(expected, box_with_array) |
1498 | 1505 | 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 | + ) |
1500 | 1509 | with pytest.raises(TypeError, match=msg): |
1501 | 1510 | offset - vec |
1502 | 1511 |
|
@@ -1985,7 +1994,9 @@ def test_operators_datetimelike_with_timezones(self): |
1985 | 1994 | result = dt1 - td1[0] |
1986 | 1995 | exp = (dt1.dt.tz_localize(None) - td1[0]).dt.tz_localize(tz) |
1987 | 1996 | 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 | + ) |
1989 | 2000 | with pytest.raises(TypeError, match=msg): |
1990 | 2001 | td1[0] - dt1 |
1991 | 2002 |
|
|
0 commit comments