Skip to content

Commit 0b2bd61

Browse files
add some xfails
1 parent d414dc9 commit 0b2bd61

33 files changed

+176
-10
lines changed

pandas/tests/apply/test_invalid_arg.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import numpy as np
1313
import pytest
1414

15+
from pandas._config import using_string_dtype
16+
1517
from pandas.errors import SpecificationError
1618

1719
from pandas import (
@@ -209,6 +211,8 @@ def transform(row):
209211
data.apply(transform, axis=1)
210212

211213

214+
# we should raise a proper TypeError instead of propagating the pyarrow error
215+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
212216
@pytest.mark.parametrize(
213217
"df, func, expected",
214218
tm.get_cython_table_params(
@@ -229,6 +233,8 @@ def test_agg_cython_table_raises_frame(df, func, expected, axis, using_infer_str
229233
df.agg(func, axis=axis)
230234

231235

236+
# we should raise a proper TypeError instead of propagating the pyarrow error
237+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
232238
@pytest.mark.parametrize(
233239
"series, func, expected",
234240
chain(

pandas/tests/apply/test_numba.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ def test_numba_nonunique_unsupported(apply_axis):
104104

105105

106106
def test_numba_unsupported_dtypes(apply_axis):
107+
pytest.importorskip("pyarrow")
107108
f = lambda x: x
108109
df = DataFrame({"a": [1, 2], "b": ["a", "b"], "c": [4, 5]})
109110
df["c"] = df["c"].astype("double[pyarrow]")

pandas/tests/arrays/boolean/test_arithmetic.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
import numpy as np
44
import pytest
55

6+
from pandas._config import using_string_dtype
7+
8+
from pandas.compat import HAS_PYARROW
9+
610
import pandas as pd
711
import pandas._testing as tm
812

@@ -90,6 +94,9 @@ def test_op_int8(left_array, right_array, opname):
9094
# -----------------------------------------------------------------------------
9195

9296

97+
@pytest.mark.xfail(
98+
using_string_dtype() and not HAS_PYARROW, reason="TODO(infer_string)"
99+
)
93100
def test_error_invalid_values(data, all_arithmetic_operators, using_infer_string):
94101
# invalid ops
95102

pandas/tests/extension/base/ops.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ class BaseArithmeticOpsTests(BaseOpsUtil):
140140
series_array_exc: type[Exception] | None = TypeError
141141
divmod_exc: type[Exception] | None = TypeError
142142

143+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
143144
def test_arith_series_with_scalar(self, data, all_arithmetic_operators):
144145
# series & scalar
145146
if all_arithmetic_operators == "__rmod__" and is_string_dtype(data.dtype):
@@ -149,6 +150,7 @@ def test_arith_series_with_scalar(self, data, all_arithmetic_operators):
149150
ser = pd.Series(data)
150151
self.check_opname(ser, op_name, ser.iloc[0])
151152

153+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
152154
def test_arith_frame_with_scalar(self, data, all_arithmetic_operators):
153155
# frame & scalar
154156
if all_arithmetic_operators == "__rmod__" and is_string_dtype(data.dtype):
@@ -158,12 +160,14 @@ def test_arith_frame_with_scalar(self, data, all_arithmetic_operators):
158160
df = pd.DataFrame({"A": data})
159161
self.check_opname(df, op_name, data[0])
160162

163+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
161164
def test_arith_series_with_array(self, data, all_arithmetic_operators):
162165
# ndarray & other series
163166
op_name = all_arithmetic_operators
164167
ser = pd.Series(data)
165168
self.check_opname(ser, op_name, pd.Series([ser.iloc[0]] * len(ser)))
166169

170+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
167171
def test_divmod(self, data):
168172
ser = pd.Series(data)
169173
self._check_divmod_op(ser, divmod, 1)
@@ -179,6 +183,7 @@ def test_divmod_series_array(self, data, data_for_twos):
179183
other = pd.Series(other)
180184
self._check_divmod_op(other, ops.rdivmod, ser)
181185

186+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
182187
def test_add_series_with_extension_array(self, data):
183188
# Check adding an ExtensionArray to a Series of the same dtype matches
184189
# the behavior of adding the arrays directly and then wrapping in a

pandas/tests/extension/test_categorical.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ def test_map(self, data, na_action):
140140
result = data.map(lambda x: x, na_action=na_action)
141141
tm.assert_extension_array_equal(result, data)
142142

143+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
143144
def test_arith_frame_with_scalar(self, data, all_arithmetic_operators, request):
144145
# frame & scalar
145146
op_name = all_arithmetic_operators
@@ -151,6 +152,7 @@ def test_arith_frame_with_scalar(self, data, all_arithmetic_operators, request):
151152
)
152153
super().test_arith_frame_with_scalar(data, op_name)
153154

155+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
154156
def test_arith_series_with_scalar(self, data, all_arithmetic_operators, request):
155157
op_name = all_arithmetic_operators
156158
if op_name == "__rmod__":

pandas/tests/extension/test_numpy.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import numpy as np
2020
import pytest
2121

22+
from pandas._config import using_string_dtype
23+
2224
from pandas.core.dtypes.dtypes import NumpyEADtype
2325

2426
import pandas as pd
@@ -255,13 +257,15 @@ def test_insert_invalid(self, data, invalid_scalar):
255257
frame_scalar_exc = None
256258
series_array_exc = None
257259

260+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
258261
def test_divmod(self, data):
259262
divmod_exc = None
260263
if data.dtype.kind == "O":
261264
divmod_exc = TypeError
262265
self.divmod_exc = divmod_exc
263266
super().test_divmod(data)
264267

268+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
265269
def test_divmod_series_array(self, data):
266270
ser = pd.Series(data)
267271
exc = None
@@ -270,6 +274,7 @@ def test_divmod_series_array(self, data):
270274
self.divmod_exc = exc
271275
self._check_divmod_op(ser, divmod, data)
272276

277+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
273278
def test_arith_series_with_scalar(self, data, all_arithmetic_operators, request):
274279
opname = all_arithmetic_operators
275280
series_scalar_exc = None
@@ -283,6 +288,7 @@ def test_arith_series_with_scalar(self, data, all_arithmetic_operators, request)
283288
self.series_scalar_exc = series_scalar_exc
284289
super().test_arith_series_with_scalar(data, all_arithmetic_operators)
285290

291+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
286292
def test_arith_series_with_array(self, data, all_arithmetic_operators):
287293
opname = all_arithmetic_operators
288294
series_array_exc = None
@@ -291,6 +297,7 @@ def test_arith_series_with_array(self, data, all_arithmetic_operators):
291297
self.series_array_exc = series_array_exc
292298
super().test_arith_series_with_array(data, all_arithmetic_operators)
293299

300+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
294301
def test_arith_frame_with_scalar(self, data, all_arithmetic_operators, request):
295302
opname = all_arithmetic_operators
296303
frame_scalar_exc = None

pandas/tests/frame/indexing/test_where.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
from pandas._config import using_string_dtype
88

9+
from pandas.compat import HAS_PYARROW
10+
911
from pandas.core.dtypes.common import is_scalar
1012

1113
import pandas as pd
@@ -1018,6 +1020,9 @@ def test_where_producing_ea_cond_for_np_dtype():
10181020
tm.assert_frame_equal(result, expected)
10191021

10201022

1023+
@pytest.mark.xfail(
1024+
using_string_dtype() and not HAS_PYARROW, reason="TODO(infer_string)", strict=False
1025+
)
10211026
@pytest.mark.parametrize(
10221027
"replacement", [0.001, True, "snake", None, datetime(2022, 5, 4)]
10231028
)

pandas/tests/frame/methods/test_info.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from pandas._config import using_string_dtype
1111

1212
from pandas.compat import (
13+
HAS_PYARROW,
1314
IS64,
1415
PYPY,
1516
)
@@ -520,7 +521,7 @@ def test_info_int_columns():
520521
assert result == expected
521522

522523

523-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
524+
@pytest.mark.xfail(using_string_dtype() and HAS_PYARROW, reason="TODO(infer_string)")
524525
def test_memory_usage_empty_no_warning():
525526
# GH#50066
526527
df = DataFrame(index=["a", "b"])

pandas/tests/frame/methods/test_rank.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
import numpy as np
77
import pytest
88

9+
from pandas._config import using_string_dtype
10+
911
from pandas._libs.algos import (
1012
Infinity,
1113
NegInfinity,
1214
)
15+
from pandas.compat import HAS_PYARROW
1316

1417
from pandas import (
1518
DataFrame,
@@ -464,9 +467,18 @@ def test_rank_inf_nans_na_option(
464467
],
465468
)
466469
def test_rank_object_first(
467-
self, frame_or_series, na_option, ascending, expected, using_infer_string
470+
self,
471+
request,
472+
frame_or_series,
473+
na_option,
474+
ascending,
475+
expected,
476+
using_infer_string,
468477
):
469478
obj = frame_or_series(["foo", "foo", None, "foo"])
479+
if using_string_dtype() and not HAS_PYARROW and isinstance(obj, Series):
480+
request.applymarker(pytest.mark.xfail(reason="TODO(infer_string)"))
481+
470482
result = obj.rank(method="first", na_option=na_option, ascending=ascending)
471483
expected = frame_or_series(expected)
472484
if using_infer_string and isinstance(obj, Series):

pandas/tests/frame/methods/test_value_counts.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import numpy as np
22
import pytest
33

4+
from pandas._config import using_string_dtype
5+
6+
from pandas.compat import HAS_PYARROW
7+
48
import pandas as pd
59
import pandas._testing as tm
610

@@ -132,6 +136,9 @@ def test_data_frame_value_counts_dropna_true(nulls_fixture):
132136
tm.assert_series_equal(result, expected)
133137

134138

139+
@pytest.mark.xfail(
140+
using_string_dtype() and not HAS_PYARROW, reason="TODO(infer_string)"
141+
)
135142
def test_data_frame_value_counts_dropna_false(nulls_fixture):
136143
# GH 41334
137144
df = pd.DataFrame(

pandas/tests/frame/test_api.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
from pandas._config import using_string_dtype
99
from pandas._config.config import option_context
1010

11+
from pandas.compat import HAS_PYARROW
12+
1113
import pandas as pd
1214
from pandas import (
1315
DataFrame,
@@ -113,7 +115,9 @@ def test_not_hashable(self):
113115
with pytest.raises(TypeError, match=msg):
114116
hash(empty_frame)
115117

116-
@pytest.mark.xfail(using_string_dtype(), reason="surrogates not allowed")
118+
@pytest.mark.xfail(
119+
using_string_dtype() and HAS_PYARROW, reason="surrogates not allowed"
120+
)
117121
def test_column_name_contains_unicode_surrogate(self):
118122
# GH 25509
119123
colname = "\ud83d"

pandas/tests/frame/test_arithmetic.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
from pandas._config import using_string_dtype
1515

16+
from pandas.compat import HAS_PYARROW
17+
1618
import pandas as pd
1719
from pandas import (
1820
DataFrame,
@@ -1542,7 +1544,9 @@ def test_comparisons(self, simple_frame, float_frame, func):
15421544
with pytest.raises(ValueError, match=msg):
15431545
func(simple_frame, simple_frame[:2])
15441546

1545-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
1547+
@pytest.mark.xfail(
1548+
using_string_dtype() and HAS_PYARROW, reason="TODO(infer_string)"
1549+
)
15461550
def test_strings_to_numbers_comparisons_raises(self, compare_operators_no_eq_ne):
15471551
# GH 11565
15481552
df = DataFrame(

pandas/tests/frame/test_constructors.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from pandas._config import using_string_dtype
2525

2626
from pandas._libs import lib
27+
from pandas.compat import HAS_PYARROW
2728
from pandas.compat.numpy import np_version_gt2
2829
from pandas.errors import IntCastingNaNError
2930

@@ -299,7 +300,7 @@ def test_constructor_dtype_nocast_view_2d_array(self):
299300
df2 = DataFrame(df.values, dtype=df[0].dtype)
300301
assert df2._mgr.blocks[0].values.flags.c_contiguous
301302

302-
@pytest.mark.xfail(using_string_dtype(), reason="conversion copies")
303+
@pytest.mark.xfail(using_string_dtype() and HAS_PYARROW, reason="conversion copies")
303304
def test_1d_object_array_does_not_copy(self):
304305
# https://github.com/pandas-dev/pandas/issues/39272
305306
arr = np.array(["a", "b"], dtype="object")

pandas/tests/frame/test_logical_ops.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
import numpy as np
55
import pytest
66

7+
from pandas._config import using_string_dtype
8+
9+
from pandas.compat import HAS_PYARROW
10+
711
from pandas import (
812
CategoricalIndex,
913
DataFrame,
@@ -96,6 +100,9 @@ def test_logical_ops_int_frame(self):
96100
res_ser = df1a_int["A"] | df1a_bool["A"]
97101
tm.assert_series_equal(res_ser, df1a_bool["A"])
98102

103+
@pytest.mark.xfail(
104+
using_string_dtype() and not HAS_PYARROW, reason="TODO(infer_string)"
105+
)
99106
def test_logical_ops_invalid(self, using_infer_string):
100107
# GH#5808
101108

pandas/tests/frame/test_reductions.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ def float_frame_with_na():
226226
class TestDataFrameAnalytics:
227227
# ---------------------------------------------------------------------
228228
# Reductions
229+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
229230
@pytest.mark.parametrize("axis", [0, 1])
230231
@pytest.mark.parametrize(
231232
"opname",
@@ -431,6 +432,7 @@ def test_stat_operators_attempt_obj_array(self, method, df, axis):
431432
expected[expected.isna()] = None
432433
tm.assert_series_equal(result, expected)
433434

435+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
434436
@pytest.mark.parametrize("op", ["mean", "std", "var", "skew", "kurt", "sem"])
435437
def test_mixed_ops(self, op):
436438
# GH#16116
@@ -532,7 +534,7 @@ def test_mean_mixed_string_decimal(self):
532534
df = DataFrame(d)
533535

534536
with pytest.raises(
535-
TypeError, match="unsupported operand type|does not support"
537+
TypeError, match="unsupported operand type|does not support|Cannot perform"
536538
):
537539
df.mean()
538540
result = df[["A", "C"]].mean()
@@ -690,6 +692,7 @@ def test_mode_dropna(self, dropna, expected):
690692
expected = DataFrame(expected)
691693
tm.assert_frame_equal(result, expected)
692694

695+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
693696
def test_mode_sortwarning(self, using_infer_string):
694697
# Check for the warning that is raised when the mode
695698
# results cannot be sorted
@@ -979,7 +982,7 @@ def test_sum_mixed_datetime(self):
979982

980983
def test_mean_corner(self, float_frame, float_string_frame):
981984
# unit test when have object data
982-
msg = "Could not convert|does not support"
985+
msg = "Could not convert|does not support|Cannot perform"
983986
with pytest.raises(TypeError, match=msg):
984987
float_string_frame.mean(axis=0)
985988

@@ -1093,6 +1096,7 @@ def test_idxmin_empty(self, index, skipna, axis):
10931096
expected = Series(dtype=index.dtype)
10941097
tm.assert_series_equal(result, expected)
10951098

1099+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
10961100
@pytest.mark.parametrize("numeric_only", [True, False])
10971101
def test_idxmin_numeric_only(self, numeric_only):
10981102
df = DataFrame({"a": [2, 3, 1], "b": [2, 1, 1], "c": list("xyx")})
@@ -1143,6 +1147,7 @@ def test_idxmax_empty(self, index, skipna, axis):
11431147
expected = Series(dtype=index.dtype)
11441148
tm.assert_series_equal(result, expected)
11451149

1150+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
11461151
@pytest.mark.parametrize("numeric_only", [True, False])
11471152
def test_idxmax_numeric_only(self, numeric_only):
11481153
df = DataFrame({"a": [2, 3, 1], "b": [2, 1, 1], "c": list("xyx")})
@@ -1964,7 +1969,7 @@ def test_minmax_extensionarray(method, numeric_only):
19641969
def test_frame_mixed_numeric_object_with_timestamp(ts_value):
19651970
# GH 13912
19661971
df = DataFrame({"a": [1], "b": [1.1], "c": ["foo"], "d": [ts_value]})
1967-
with pytest.raises(TypeError, match="does not support operation"):
1972+
with pytest.raises(TypeError, match="does not support operation|Cannot perform"):
19681973
df.sum()
19691974

19701975

0 commit comments

Comments
 (0)