Skip to content

Commit b345971

Browse files
committed
update test
1 parent 103f037 commit b345971

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

pandas/core/arrays/arrow/array.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -649,15 +649,7 @@ def _evaluate_op_method(self, other, op, arrow_funcs):
649649
if pc_func is NotImplemented:
650650
raise NotImplementedError(f"{op.__name__} not implemented.")
651651

652-
try:
653-
result = pc_func(self._pa_array, other)
654-
except pa.lib.ArrowNotImplementedError:
655-
if op in [operator.add, roperator.radd, operator.sub, roperator.rsub]:
656-
# By returning NotImplemented we get standard message with a
657-
# TypeError
658-
return NotImplemented
659-
raise
660-
652+
result = pc_func(self._pa_array, other)
661653
return type(self)(result)
662654

663655
def _logical_method(self, other, op):

pandas/tests/arithmetic/common.py

+16-5
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ def assert_cannot_add(left, right, msg="cannot add"):
3333
right + left
3434

3535

36-
def assert_invalid_addsub_type(left, right, msg=None):
36+
def assert_invalid_addsub_type(
37+
left, right, msg=None, can_be_not_implemented: bool = False
38+
):
3739
"""
3840
Helper to assert that left and right can be neither added nor subtracted.
3941
@@ -42,14 +44,23 @@ def assert_invalid_addsub_type(left, right, msg=None):
4244
left : object
4345
right : object
4446
msg : str or None, default None
47+
can_be_not_implemented : bool, default False
48+
Whether to accept NotImplementedError in addition to TypeError
4549
"""
46-
with pytest.raises(TypeError, match=msg):
50+
51+
errs = TypeError
52+
if can_be_not_implemented:
53+
# really we are interested in pa.lib.ArrowNotImplementedError, which
54+
# is a subclass of NotImplementedError
55+
errs = (TypeError, NotImplementedError)
56+
57+
with pytest.raises(errs, match=msg):
4758
left + right
48-
with pytest.raises(TypeError, match=msg):
59+
with pytest.raises(errs, match=msg):
4960
right + left
50-
with pytest.raises(TypeError, match=msg):
61+
with pytest.raises(errs, match=msg):
5162
left - right
52-
with pytest.raises(TypeError, match=msg):
63+
with pytest.raises(errs, match=msg):
5364
right - left
5465

5566

pandas/tests/arithmetic/test_datetime64.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1195,7 +1195,7 @@ def test_dt64arr_addsub_time_objects_raises(
11951195
warn_msg = "Pandas type inference with a sequence of `datetime.time` objects"
11961196
warn = None
11971197
if future is True:
1198-
msgs.append("cannot subtract DatetimeArray from ArrowExtensionArray")
1198+
msgs.append(r"Function '(add|subtract)_checked' has no kernel")
11991199
elif future is None:
12001200
warn = FutureWarning
12011201

@@ -1210,7 +1210,7 @@ def test_dt64arr_addsub_time_objects_raises(
12101210
# we aren't testing that here, so ignore.
12111211
warnings.simplefilter("ignore", PerformanceWarning)
12121212

1213-
assert_invalid_addsub_type(obj1, obj2, msg=msg)
1213+
assert_invalid_addsub_type(obj1, obj2, msg=msg, can_be_not_implemented=True)
12141214

12151215
# -------------------------------------------------------------
12161216
# Other invalid operations

0 commit comments

Comments
 (0)