Skip to content

Commit 92ac5e0

Browse files
authored
TST: GH30999 address all bare pytest.raises in pandas/tests/arrays/boolean/test_arithmetic.py (pandas-dev#38849)
1 parent c15f3df commit 92ac5e0

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

pandas/tests/arrays/boolean/test_arithmetic.py

+22-5
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,11 @@ def test_add_mul(left_array, right_array, opname, exp):
4646

4747

4848
def test_sub(left_array, right_array):
49-
with pytest.raises(TypeError):
50-
# numpy points to ^ operator or logical_xor function instead
49+
msg = (
50+
r"numpy boolean subtract, the `-` operator, is (?:deprecated|not supported), "
51+
r"use the bitwise_xor, the `\^` operator, or the logical_xor function instead\."
52+
)
53+
with pytest.raises(TypeError, match=msg):
5154
left_array - right_array
5255

5356

@@ -92,13 +95,27 @@ def test_error_invalid_values(data, all_arithmetic_operators):
9295
ops = getattr(s, op)
9396

9497
# invalid scalars
95-
with pytest.raises(TypeError):
98+
msg = (
99+
"did not contain a loop with signature matching types|"
100+
"BooleanArray cannot perform the operation|"
101+
"not supported for the input types, and the inputs could not be safely coerced "
102+
"to any supported types according to the casting rule ''safe''"
103+
)
104+
with pytest.raises(TypeError, match=msg):
96105
ops("foo")
97-
with pytest.raises(TypeError):
106+
msg = (
107+
r"unsupported operand type\(s\) for|"
108+
"Concatenation operation is not implemented for NumPy arrays"
109+
)
110+
with pytest.raises(TypeError, match=msg):
98111
ops(pd.Timestamp("20180101"))
99112

100113
# invalid array-likes
101114
if op not in ("__mul__", "__rmul__"):
102115
# TODO(extension) numpy's mul with object array sees booleans as numbers
103-
with pytest.raises(TypeError):
116+
msg = (
117+
r"unsupported operand type\(s\) for|can only concatenate str|"
118+
"not all arguments converted during string formatting"
119+
)
120+
with pytest.raises(TypeError, match=msg):
104121
ops(pd.Series("foo", index=s.index))

0 commit comments

Comments
 (0)