diff --git a/pandas/tests/arithmetic/test_numeric.py b/pandas/tests/arithmetic/test_numeric.py index 202e30287881f..792b8bb4f25ab 100644 --- a/pandas/tests/arithmetic/test_numeric.py +++ b/pandas/tests/arithmetic/test_numeric.py @@ -1305,3 +1305,35 @@ def test_dataframe_div_silenced(): ) with tm.assert_produces_warning(None): pdf1.div(pdf2, fill_value=0) + + +class TestNumericArraylikeArithmeticWithBool: + @pytest.mark.parametrize("num", [complex(1), np.int64(1), 1, 1.0]) + def test_array_like_bool_and_num_op_coerce( + self, num, all_arithmetic_functions, box_with_array + ): + # https://github.com/pandas-dev/pandas/issues/18549 + op = all_arithmetic_functions + + if op.__name__ in [ + "floordiv", + "mod", + "mul", + "pow", + "rfloordiv", + "rpow", + "rmod", + "rmul", + "rtruediv", + "truediv", + ]: + pytest.xfail("Arithmetic operation is not supported") + + bool_box = [True] + expected = [op(num, num)] + + bool_box = tm.box_expected(bool_box, box_with_array) + expected = tm.box_expected(expected, box_with_array) + + tm.assert_equal(expected, op(bool_box, num)) + tm.assert_equal(expected, op(num, bool_box))