Skip to content

Commit 5b571c0

Browse files
jbrockmendelmroeschke
authored andcommitted
TST (string): more targeted xfails in test_string.py (#59703)
* TST (string): more targeted xfails in test_string.py * Fix no-pyarrow test * Update pandas/tests/extension/test_string.py Co-authored-by: Matthew Roeschke <[email protected]> * Update pandas/tests/extension/test_string.py Co-authored-by: Matthew Roeschke <[email protected]> --------- Co-authored-by: Matthew Roeschke <[email protected]>
1 parent 77a2326 commit 5b571c0

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

pandas/tests/extension/test_string.py

+31-5
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import numpy as np
2222
import pytest
2323

24-
from pandas._config import using_string_dtype
24+
from pandas.compat import HAS_PYARROW
2525

2626
import pandas as pd
2727
import pandas._testing as tm
@@ -30,10 +30,6 @@
3030
from pandas.core.arrays.string_ import StringDtype
3131
from pandas.tests.extension import base
3232

33-
pytestmark = pytest.mark.xfail(
34-
using_string_dtype(), reason="TODO(infer_string)", strict=False
35-
)
36-
3733

3834
def maybe_split_array(arr, chunked):
3935
if not chunked:
@@ -220,6 +216,36 @@ def test_compare_scalar(self, data, comparison_op):
220216
def test_groupby_extension_apply(self, data_for_grouping, groupby_apply_op):
221217
super().test_groupby_extension_apply(data_for_grouping, groupby_apply_op)
222218

219+
def test_combine_add(self, data_repeated, using_infer_string, request):
220+
dtype = next(data_repeated(1)).dtype
221+
if using_infer_string and (
222+
(dtype.na_value is pd.NA) and dtype.storage == "python"
223+
):
224+
mark = pytest.mark.xfail(
225+
reason="The pointwise operation result will be inferred to "
226+
"string[nan, pyarrow], which does not match the input dtype"
227+
)
228+
request.applymarker(mark)
229+
super().test_combine_add(data_repeated)
230+
231+
def test_arith_series_with_array(
232+
self, data, all_arithmetic_operators, using_infer_string, request
233+
):
234+
dtype = data.dtype
235+
if (
236+
using_infer_string
237+
and all_arithmetic_operators == "__radd__"
238+
and (
239+
(dtype.na_value is pd.NA) or (dtype.storage == "python" and HAS_PYARROW)
240+
)
241+
):
242+
mark = pytest.mark.xfail(
243+
reason="The pointwise operation result will be inferred to "
244+
"string[nan, pyarrow], which does not match the input dtype"
245+
)
246+
request.applymarker(mark)
247+
super().test_arith_series_with_array(data, all_arithmetic_operators)
248+
223249

224250
class Test2DCompat(base.Dim2CompatTests):
225251
@pytest.fixture(autouse=True)

0 commit comments

Comments
 (0)