Skip to content

Commit

Permalink
Fix arithmetic test folder for arrow string option (#56122)
Browse files Browse the repository at this point in the history
  • Loading branch information
phofl authored Nov 26, 2023
1 parent ac45f88 commit b8d0471
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions pandas/tests/arithmetic/test_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import numpy as np
import pytest

from pandas._config import using_pyarrow_string_dtype

import pandas as pd
from pandas import (
Series,
Expand Down Expand Up @@ -172,7 +174,12 @@ def test_objarr_add_invalid(self, op, box_with_array):

obj_ser = tm.box_expected(obj_ser, box)
msg = "|".join(
["can only concatenate str", "unsupported operand type", "must be str"]
[
"can only concatenate str",
"unsupported operand type",
"must be str",
"has no kernel",
]
)
with pytest.raises(Exception, match=msg):
op(obj_ser, 1)
Expand Down Expand Up @@ -290,6 +297,7 @@ def test_iadd_string(self):
index += "_x"
assert "a_x" in index

@pytest.mark.xfail(using_pyarrow_string_dtype(), reason="add doesn't work")
def test_add(self):
index = tm.makeStringIndex(100)
expected = pd.Index(index.values * 2)
Expand All @@ -304,17 +312,24 @@ def test_add(self):
expected = pd.Index(["1a", "1b", "1c"])
tm.assert_index_equal("1" + index, expected)

def test_sub_fail(self):
def test_sub_fail(self, using_infer_string):
index = tm.makeStringIndex(100)

msg = "unsupported operand type|Cannot broadcast"
with pytest.raises(TypeError, match=msg):
if using_infer_string:
import pyarrow as pa

err = pa.lib.ArrowNotImplementedError
msg = "has no kernel"
else:
err = TypeError
msg = "unsupported operand type|Cannot broadcast"
with pytest.raises(err, match=msg):
index - "a"
with pytest.raises(TypeError, match=msg):
with pytest.raises(err, match=msg):
index - index
with pytest.raises(TypeError, match=msg):
with pytest.raises(err, match=msg):
index - index.tolist()
with pytest.raises(TypeError, match=msg):
with pytest.raises(err, match=msg):
index.tolist() - index

def test_sub_object(self):
Expand Down

0 comments on commit b8d0471

Please sign in to comment.