diff --git a/pandas/tests/arrays/boolean/test_arithmetic.py b/pandas/tests/arrays/boolean/test_arithmetic.py index 01de64568a011..f8f1af4c3da51 100644 --- a/pandas/tests/arrays/boolean/test_arithmetic.py +++ b/pandas/tests/arrays/boolean/test_arithmetic.py @@ -46,8 +46,11 @@ def test_add_mul(left_array, right_array, opname, exp): def test_sub(left_array, right_array): - with pytest.raises(TypeError): - # numpy points to ^ operator or logical_xor function instead + msg = ( + r"numpy boolean subtract, the `-` operator, is (?:deprecated|not supported), " + r"use the bitwise_xor, the `\^` operator, or the logical_xor function instead\." + ) + with pytest.raises(TypeError, match=msg): left_array - right_array @@ -92,13 +95,27 @@ def test_error_invalid_values(data, all_arithmetic_operators): ops = getattr(s, op) # invalid scalars - with pytest.raises(TypeError): + msg = ( + "did not contain a loop with signature matching types|" + "BooleanArray cannot perform the operation|" + "not supported for the input types, and the inputs could not be safely coerced " + "to any supported types according to the casting rule ''safe''" + ) + with pytest.raises(TypeError, match=msg): ops("foo") - with pytest.raises(TypeError): + msg = ( + r"unsupported operand type\(s\) for|" + "Concatenation operation is not implemented for NumPy arrays" + ) + with pytest.raises(TypeError, match=msg): ops(pd.Timestamp("20180101")) # invalid array-likes if op not in ("__mul__", "__rmul__"): # TODO(extension) numpy's mul with object array sees booleans as numbers - with pytest.raises(TypeError): + msg = ( + r"unsupported operand type\(s\) for|can only concatenate str|" + "not all arguments converted during string formatting" + ) + with pytest.raises(TypeError, match=msg): ops(pd.Series("foo", index=s.index))