Skip to content

Commit b8d0471

Browse files
authored
Fix arithmetic test folder for arrow string option (#56122)
1 parent ac45f88 commit b8d0471

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

‎pandas/tests/arithmetic/test_object.py

+22-7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import numpy as np
99
import pytest
1010

11+
from pandas._config import using_pyarrow_string_dtype
12+
1113
import pandas as pd
1214
from pandas import (
1315
Series,
@@ -172,7 +174,12 @@ def test_objarr_add_invalid(self, op, box_with_array):
172174

173175
obj_ser = tm.box_expected(obj_ser, box)
174176
msg = "|".join(
175-
["can only concatenate str", "unsupported operand type", "must be str"]
177+
[
178+
"can only concatenate str",
179+
"unsupported operand type",
180+
"must be str",
181+
"has no kernel",
182+
]
176183
)
177184
with pytest.raises(Exception, match=msg):
178185
op(obj_ser, 1)
@@ -290,6 +297,7 @@ def test_iadd_string(self):
290297
index += "_x"
291298
assert "a_x" in index
292299

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

307-
def test_sub_fail(self):
315+
def test_sub_fail(self, using_infer_string):
308316
index = tm.makeStringIndex(100)
309317

310-
msg = "unsupported operand type|Cannot broadcast"
311-
with pytest.raises(TypeError, match=msg):
318+
if using_infer_string:
319+
import pyarrow as pa
320+
321+
err = pa.lib.ArrowNotImplementedError
322+
msg = "has no kernel"
323+
else:
324+
err = TypeError
325+
msg = "unsupported operand type|Cannot broadcast"
326+
with pytest.raises(err, match=msg):
312327
index - "a"
313-
with pytest.raises(TypeError, match=msg):
328+
with pytest.raises(err, match=msg):
314329
index - index
315-
with pytest.raises(TypeError, match=msg):
330+
with pytest.raises(err, match=msg):
316331
index - index.tolist()
317-
with pytest.raises(TypeError, match=msg):
332+
with pytest.raises(err, match=msg):
318333
index.tolist() - index
319334

320335
def test_sub_object(self):

0 commit comments

Comments
 (0)