Skip to content

Commit c4f5f1d

Browse files
author
MomIsBestFriend
committed
Fixed some bare pytest raises
1 parent a3b045c commit c4f5f1d

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

pandas/tests/internals/test_internals.py

+20-2
Original file line numberDiff line numberDiff line change
@@ -1250,7 +1250,16 @@ def test_binop_m(self, op, value):
12501250
s = pd.DataFrame({"A": [e.value, e.value]}, dtype=e.dtype)
12511251

12521252
if op in [operator.mul, operator.pow]:
1253-
with pytest.raises(TypeError):
1253+
# operator.mul will raise an external error message.
1254+
msg = (
1255+
None
1256+
if op == operator.mul
1257+
else (
1258+
f"cannot perform __{op.__name__}__ "
1259+
"with this index type: TimedeltaArray"
1260+
)
1261+
)
1262+
with pytest.raises(TypeError, match=msg):
12541263
op(s, e.value)
12551264
else:
12561265
result = op(s, e.value).dtypes
@@ -1272,7 +1281,16 @@ def test_binop_m_capitalized(self, op, value):
12721281
operator.pow,
12731282
operator.truediv,
12741283
]:
1275-
with pytest.raises(TypeError):
1284+
# operator.add will raise an external error message.
1285+
msg = (
1286+
None
1287+
if op == operator.add
1288+
else (
1289+
f"cannot perform __{op.__name__}__ "
1290+
"with this index type: DatetimeArray"
1291+
)
1292+
)
1293+
with pytest.raises(TypeError, match=msg):
12761294
op(s, e.value)
12771295
else:
12781296
result = op(s, e.value).dtypes

0 commit comments

Comments
 (0)