Skip to content

Commit

Permalink
TST: GH30999 address all bare pytest.raises in pandas/tests/arrays/bo…
Browse files Browse the repository at this point in the history
…olean/test_arithmetic.py (pandas-dev#38849)
  • Loading branch information
moink authored and luckyvs1 committed Jan 20, 2021
1 parent 48d28ee commit d737f8b
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions pandas/tests/arrays/boolean/test_arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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))

0 comments on commit d737f8b

Please sign in to comment.