Skip to content

Commit 5ff8410

Browse files
author
MomIsBestFriend
committed
Fixed some bare pytest raises
1 parent 6932a2c commit 5ff8410

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

pandas/tests/internals/test_internals.py

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,21 +1164,6 @@ def any(self, axis=None):
11641164

11651165

11661166
class TestCanHoldElement:
1167-
#############################
1168-
1169-
# THINGS TO SOLVE BEFORE MERGING THIS PULL REQUEST:
1170-
1171-
# Delete this comment :)
1172-
1173-
# Should "ops" be called "_ops" instead ?
1174-
1175-
# What to do about the comment that was in the "else" block?
1176-
# """
1177-
# FIXME: Since dispatching to Series, this test no longer
1178-
# asserts anything meaningful
1179-
# """
1180-
1181-
#############################
11821167

11831168
ops = pytest.mark.parametrize(
11841169
"op",
@@ -1265,7 +1250,16 @@ def test_binop_m(self, op, value):
12651250
s = pd.DataFrame({"A": [e.value, e.value]}, dtype=e.dtype)
12661251

12671252
if op in [operator.mul, operator.pow]:
1268-
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):
12691263
op(s, e.value)
12701264
else:
12711265
result = op(s, e.value).dtypes
@@ -1287,7 +1281,16 @@ def test_binop_m_capitalized(self, op, value):
12871281
operator.pow,
12881282
operator.truediv,
12891283
]:
1290-
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):
12911294
op(s, e.value)
12921295
else:
12931296
result = op(s, e.value).dtypes

0 commit comments

Comments
 (0)