Skip to content

Commit ff1f57e

Browse files
fix expected exception in test_arrow.py
1 parent ae69206 commit ff1f57e

File tree

2 files changed

+5
-21
lines changed

2 files changed

+5
-21
lines changed

pandas/core/arrays/arrow/array.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ def _evaluate_op_method(self, other, op, arrow_funcs) -> Self:
763763
result = pc.binary_join_element_wise(self._pa_array, other, sep)
764764
elif op is roperator.radd:
765765
result = pc.binary_join_element_wise(other, self._pa_array, sep)
766-
except pa.lib.ArrowNotImplementedError as err:
766+
except pa.ArrowNotImplementedError as err:
767767
raise TypeError(
768768
self._op_method_error_message(other_original, op)
769769
) from err
@@ -804,7 +804,7 @@ def _evaluate_op_method(self, other, op, arrow_funcs) -> Self:
804804

805805
try:
806806
result = pc_func(self._pa_array, other)
807-
except pa.lib.ArrowNotImplementedError as err:
807+
except pa.ArrowNotImplementedError as err:
808808
raise TypeError(self._op_method_error_message(other_original, op)) from err
809809
return type(self)(result)
810810

pandas/tests/extension/test_arrow.py

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ def _get_expected_exception(
944944
self, op_name: str, obj, other
945945
) -> type[Exception] | None:
946946
if op_name in ("__divmod__", "__rdivmod__"):
947-
return self.divmod_exc
947+
return (self.divmod_exc, TypeError)
948948

949949
dtype = tm.get_dtype(obj)
950950
# error: Item "dtype[Any]" of "dtype[Any] | ExtensionDtype" has no
@@ -956,7 +956,7 @@ def _get_expected_exception(
956956
"__mod__",
957957
"__rmod__",
958958
}:
959-
exc = NotImplementedError
959+
exc = (NotImplementedError, TypeError)
960960
elif arrow_temporal_supported:
961961
exc = None
962962
elif op_name in ["__add__", "__radd__"] and (
@@ -971,7 +971,7 @@ def _get_expected_exception(
971971
# TODO: in many of these cases, e.g. non-duration temporal,
972972
# these will *never* be allowed. Would it make more sense to
973973
# re-raise as TypeError, more consistent with non-pyarrow cases?
974-
exc = pa.ArrowNotImplementedError
974+
exc = (pa.ArrowNotImplementedError, TypeError)
975975
else:
976976
exc = None
977977
return exc
@@ -1027,14 +1027,6 @@ def test_arith_series_with_scalar(self, data, all_arithmetic_operators, request)
10271027

10281028
if all_arithmetic_operators == "__rmod__" and pa.types.is_binary(pa_dtype):
10291029
pytest.skip("Skip testing Python string formatting")
1030-
elif all_arithmetic_operators in ("__rmul__", "__mul__") and (
1031-
pa.types.is_binary(pa_dtype) or pa.types.is_string(pa_dtype)
1032-
):
1033-
request.applymarker(
1034-
pytest.mark.xfail(
1035-
raises=TypeError, reason="Can only string multiply by an integer."
1036-
)
1037-
)
10381030

10391031
mark = self._get_arith_xfail_marker(all_arithmetic_operators, pa_dtype)
10401032
if mark is not None:
@@ -1049,14 +1041,6 @@ def test_arith_frame_with_scalar(self, data, all_arithmetic_operators, request):
10491041
pa.types.is_string(pa_dtype) or pa.types.is_binary(pa_dtype)
10501042
):
10511043
pytest.skip("Skip testing Python string formatting")
1052-
elif all_arithmetic_operators in ("__rmul__", "__mul__") and (
1053-
pa.types.is_binary(pa_dtype) or pa.types.is_string(pa_dtype)
1054-
):
1055-
request.applymarker(
1056-
pytest.mark.xfail(
1057-
raises=TypeError, reason="Can only string multiply by an integer."
1058-
)
1059-
)
10601044

10611045
mark = self._get_arith_xfail_marker(all_arithmetic_operators, pa_dtype)
10621046
if mark is not None:

0 commit comments

Comments
 (0)