Skip to content

Commit 641346c

Browse files
ShaharNavehWillAyd
authored andcommitted
TST: Fix some bare pytest raises (#31105)
1 parent a0c7a8a commit 641346c

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

pandas/tests/internals/test_internals.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -1200,7 +1200,7 @@ def test_binop_other(self, op, value, dtype):
12001200
(operator.pow, "bool"),
12011201
}
12021202
if (op, dtype) in skip:
1203-
pytest.skip("Invalid combination {},{}".format(op, dtype))
1203+
pytest.skip(f"Invalid combination {op},{dtype}")
12041204

12051205
e = DummyElement(value, dtype)
12061206
s = pd.DataFrame({"A": [e.value, e.value]}, dtype=e.dtype)
@@ -1216,7 +1216,17 @@ def test_binop_other(self, op, value, dtype):
12161216
}
12171217

12181218
if (op, dtype) in invalid:
1219-
with pytest.raises(TypeError):
1219+
msg = (
1220+
None
1221+
if (dtype == "<M8[ns]" and op == operator.add)
1222+
or (dtype == "<m8[ns]" and op == operator.mul)
1223+
else (
1224+
f"cannot perform __{op.__name__}__ with this "
1225+
"index type: (DatetimeArray|TimedeltaArray)"
1226+
)
1227+
)
1228+
1229+
with pytest.raises(TypeError, match=msg):
12201230
op(s, e.value)
12211231
else:
12221232
# FIXME: Since dispatching to Series, this test no longer

0 commit comments

Comments
 (0)