8
8
import numpy as np
9
9
import pytest
10
10
11
+ from pandas ._config import using_pyarrow_string_dtype
12
+
11
13
import pandas as pd
12
14
from pandas import (
13
15
Series ,
@@ -172,7 +174,12 @@ def test_objarr_add_invalid(self, op, box_with_array):
172
174
173
175
obj_ser = tm .box_expected (obj_ser , box )
174
176
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
+ ]
176
183
)
177
184
with pytest .raises (Exception , match = msg ):
178
185
op (obj_ser , 1 )
@@ -290,6 +297,7 @@ def test_iadd_string(self):
290
297
index += "_x"
291
298
assert "a_x" in index
292
299
300
+ @pytest .mark .xfail (using_pyarrow_string_dtype (), reason = "add doesn't work" )
293
301
def test_add (self ):
294
302
index = tm .makeStringIndex (100 )
295
303
expected = pd .Index (index .values * 2 )
@@ -304,17 +312,24 @@ def test_add(self):
304
312
expected = pd .Index (["1a" , "1b" , "1c" ])
305
313
tm .assert_index_equal ("1" + index , expected )
306
314
307
- def test_sub_fail (self ):
315
+ def test_sub_fail (self , using_infer_string ):
308
316
index = tm .makeStringIndex (100 )
309
317
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 ):
312
327
index - "a"
313
- with pytest .raises (TypeError , match = msg ):
328
+ with pytest .raises (err , match = msg ):
314
329
index - index
315
- with pytest .raises (TypeError , match = msg ):
330
+ with pytest .raises (err , match = msg ):
316
331
index - index .tolist ()
317
- with pytest .raises (TypeError , match = msg ):
332
+ with pytest .raises (err , match = msg ):
318
333
index .tolist () - index
319
334
320
335
def test_sub_object (self ):
0 commit comments