Skip to content

Commit 9b375be

Browse files
TST (string dtype): clean-up xpasssing tests with future string dtype (#59323)
1 parent 5af55e0 commit 9b375be

14 files changed

+16
-37
lines changed

pandas/tests/arithmetic/test_object.py

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

11-
from pandas._config import using_string_dtype
12-
1311
import pandas.util._test_decorators as td
1412

1513
import pandas as pd
@@ -303,7 +301,6 @@ def test_iadd_string(self):
303301
index += "_x"
304302
assert "a_x" in index
305303

306-
@pytest.mark.xfail(using_string_dtype(), reason="add doesn't work")
307304
def test_add(self):
308305
index = pd.Index([str(i) for i in range(10)])
309306
expected = pd.Index(index.values * 2)

pandas/tests/base/test_unique.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import numpy as np
22
import pytest
33

4-
from pandas._config import using_string_dtype
5-
64
import pandas as pd
75
import pandas._testing as tm
86
from pandas.tests.base.common import allow_na_ops
@@ -100,12 +98,11 @@ def test_nunique_null(null_obj, index_or_series_obj):
10098

10199

102100
@pytest.mark.single_cpu
103-
@pytest.mark.xfail(using_string_dtype(), reason="decoding fails")
104101
def test_unique_bad_unicode(index_or_series):
105102
# regression test for #34550
106103
uval = "\ud83d" # smiley emoji
107104

108-
obj = index_or_series([uval] * 2)
105+
obj = index_or_series([uval] * 2, dtype=object)
109106
result = obj.unique()
110107

111108
if isinstance(obj, pd.Index):

pandas/tests/frame/constructors/test_from_dict.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def test_constructor_single_row(self):
4444
)
4545
tm.assert_frame_equal(result, expected)
4646

47-
@pytest.mark.skipif(using_string_dtype(), reason="columns inferring logic broken")
47+
@pytest.mark.xfail(using_string_dtype(), reason="columns inferring logic broken")
4848
def test_constructor_list_of_series(self):
4949
data = [
5050
OrderedDict([["a", 1.5], ["b", 3.0], ["c", 4.0]]),
@@ -108,6 +108,7 @@ def test_constructor_list_of_series(self):
108108
expected = DataFrame.from_dict(sdict, orient="index")
109109
tm.assert_frame_equal(result, expected)
110110

111+
@pytest.mark.xfail(using_string_dtype(), reason="columns inferring logic broken")
111112
def test_constructor_orient(self, float_string_frame):
112113
data_dict = float_string_frame.T._series
113114
recons = DataFrame.from_dict(data_dict, orient="index")

pandas/tests/frame/constructors/test_from_records.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ def test_from_records_with_datetimes(self):
5757
expected["EXPIRY"] = expected["EXPIRY"].astype("M8[s]")
5858
tm.assert_frame_equal(result, expected)
5959

60-
@pytest.mark.skipif(
61-
using_string_dtype(), reason="dtype checking logic doesn't work"
62-
)
60+
@pytest.mark.xfail(using_string_dtype(), reason="dtype checking logic doesn't work")
6361
def test_from_records_sequencelike(self):
6462
df = DataFrame(
6563
{

pandas/tests/frame/methods/test_fillna.py

+2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def test_fillna_datetime(self, datetime_frame):
6565
with pytest.raises(TypeError, match=msg):
6666
datetime_frame.fillna()
6767

68+
# TODO(infer_string) test as actual error instead of xfail
6869
@pytest.mark.xfail(using_string_dtype(), reason="can't fill 0 in string")
6970
def test_fillna_mixed_type(self, float_string_frame):
7071
mf = float_string_frame
@@ -537,6 +538,7 @@ def test_fillna_col_reordering(self):
537538
filled = df.ffill()
538539
assert df.columns.tolist() == filled.columns.tolist()
539540

541+
# TODO(infer_string) test as actual error instead of xfail
540542
@pytest.mark.xfail(using_string_dtype(), reason="can't fill 0 in string")
541543
def test_fill_corner(self, float_frame, float_string_frame):
542544
mf = float_string_frame

pandas/tests/frame/methods/test_info.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from pandas import (
1616
CategoricalIndex,
1717
DataFrame,
18+
Index,
1819
MultiIndex,
1920
Series,
2021
date_range,
@@ -360,7 +361,7 @@ def test_info_memory_usage():
360361
df = DataFrame(data)
361362
df.columns = dtypes
362363

363-
df_with_object_index = DataFrame({"a": [1]}, index=["foo"])
364+
df_with_object_index = DataFrame({"a": [1]}, index=Index(["foo"], dtype=object))
364365
df_with_object_index.info(buf=buf, memory_usage=True)
365366
res = buf.getvalue().splitlines()
366367
assert re.match(r"memory usage: [^+]+\+", res[-1])
@@ -398,25 +399,25 @@ def test_info_memory_usage():
398399

399400
@pytest.mark.skipif(PYPY, reason="on PyPy deep=True doesn't change result")
400401
def test_info_memory_usage_deep_not_pypy():
401-
df_with_object_index = DataFrame({"a": [1]}, index=["foo"])
402+
df_with_object_index = DataFrame({"a": [1]}, index=Index(["foo"], dtype=object))
402403
assert (
403404
df_with_object_index.memory_usage(index=True, deep=True).sum()
404405
> df_with_object_index.memory_usage(index=True).sum()
405406
)
406407

407-
df_object = DataFrame({"a": ["a"]})
408+
df_object = DataFrame({"a": Series(["a"], dtype=object)})
408409
assert df_object.memory_usage(deep=True).sum() > df_object.memory_usage().sum()
409410

410411

411412
@pytest.mark.xfail(not PYPY, reason="on PyPy deep=True does not change result")
412413
def test_info_memory_usage_deep_pypy():
413-
df_with_object_index = DataFrame({"a": [1]}, index=["foo"])
414+
df_with_object_index = DataFrame({"a": [1]}, index=Index(["foo"], dtype=object))
414415
assert (
415416
df_with_object_index.memory_usage(index=True, deep=True).sum()
416417
== df_with_object_index.memory_usage(index=True).sum()
417418
)
418419

419-
df_object = DataFrame({"a": ["a"]})
420+
df_object = DataFrame({"a": Series(["a"], dtype=object)})
420421
assert df_object.memory_usage(deep=True).sum() == df_object.memory_usage().sum()
421422

422423

pandas/tests/frame/methods/test_interpolate.py

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def test_interpolate_inplace(self, frame_or_series, request):
6464
assert np.shares_memory(orig, obj.values)
6565
assert orig.squeeze()[1] == 1.5
6666

67+
# TODO(infer_string) raise proper TypeError in case of string dtype
6768
@pytest.mark.xfail(
6869
using_string_dtype(), reason="interpolate doesn't work for string"
6970
)

pandas/tests/frame/test_arithmetic.py

-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
import numpy as np
1212
import pytest
1313

14-
from pandas._config import using_string_dtype
15-
1614
import pandas as pd
1715
from pandas import (
1816
DataFrame,
@@ -251,7 +249,6 @@ def test_timestamp_compare(self, left, right):
251249
with pytest.raises(TypeError, match=msg):
252250
right_f(pd.Timestamp("nat"), df)
253251

254-
@pytest.mark.xfail(using_string_dtype(), reason="can't compare string and int")
255252
def test_mixed_comparison(self):
256253
# GH#13128, GH#22163 != datetime64 vs non-dt64 should be False,
257254
# not raise TypeError

pandas/tests/indexes/interval/test_formats.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import numpy as np
22
import pytest
33

4-
from pandas._config import using_string_dtype
5-
64
from pandas import (
75
DataFrame,
86
DatetimeIndex,
@@ -42,12 +40,11 @@ def test_repr_missing(self, constructor, expected, using_infer_string, request):
4240
result = repr(obj)
4341
assert result == expected
4442

45-
@pytest.mark.xfail(using_string_dtype(), reason="repr different")
4643
def test_repr_floats(self):
4744
# GH 32553
4845

4946
markers = Series(
50-
["foo", "bar"],
47+
[1, 2],
5148
index=IntervalIndex(
5249
[
5350
Interval(left, right)
@@ -59,7 +56,7 @@ def test_repr_floats(self):
5956
),
6057
)
6158
result = str(markers)
62-
expected = "(329.973, 345.137] foo\n(345.137, 360.191] bar\ndtype: object"
59+
expected = "(329.973, 345.137] 1\n(345.137, 360.191] 2\ndtype: int64"
6360
assert result == expected
6461

6562
@pytest.mark.parametrize(

pandas/tests/indexing/test_coercion.py

-4
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
import numpy as np
1010
import pytest
1111

12-
from pandas._config import using_string_dtype
13-
1412
from pandas.compat import (
1513
IS64,
1614
is_platform_windows,
@@ -825,8 +823,6 @@ def replacer(self, how, from_key, to_key):
825823
raise ValueError
826824
return replacer
827825

828-
# Expected needs adjustment for the infer string option, seems to work as expecetd
829-
@pytest.mark.skipif(using_string_dtype(), reason="TODO: test is to complex")
830826
def test_replace_series(self, how, to_key, from_key, replacer):
831827
index = pd.Index([3, 4], name="xxx")
832828
obj = pd.Series(self.rep[from_key], index=index, name="yyy")

pandas/tests/indexing/test_indexing.py

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

11-
from pandas._config import using_string_dtype
12-
1311
from pandas.errors import IndexingError
1412

1513
from pandas.core.dtypes.common import (
@@ -426,7 +424,6 @@ def test_set_index_nan(self):
426424
)
427425
tm.assert_frame_equal(result, df)
428426

429-
@pytest.mark.xfail(using_string_dtype(), reason="can't multiply arrow strings")
430427
def test_multi_assign(self):
431428
# GH 3626, an assignment of a sub-df to a df
432429
# set float64 to avoid upcast when setting nan
@@ -652,7 +649,6 @@ def test_loc_setitem_fullindex_views(self):
652649
df.loc[df.index] = df.loc[df.index]
653650
tm.assert_frame_equal(df, df2)
654651

655-
@pytest.mark.xfail(using_string_dtype(), reason="can't set int into string")
656652
def test_rhs_alignment(self):
657653
# GH8258, tests that both rows & columns are aligned to what is
658654
# assigned to. covers both uniform data-type & multi-type cases

pandas/tests/series/methods/test_reindex.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import numpy as np
22
import pytest
33

4-
from pandas._config import using_string_dtype
5-
64
from pandas import (
75
NA,
86
Categorical,
@@ -22,7 +20,6 @@
2220
import pandas._testing as tm
2321

2422

25-
@pytest.mark.xfail(using_string_dtype(), reason="share memory doesn't work for arrow")
2623
def test_reindex(datetime_series, string_series):
2724
identity = string_series.reindex(string_series.index)
2825

pandas/tests/series/methods/test_replace.py

-1
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,6 @@ def test_replace_mixed_types_with_string(self):
359359
expected = pd.Series([1, np.nan, 3, np.nan, 4, 5], dtype=object)
360360
tm.assert_series_equal(expected, result)
361361

362-
@pytest.mark.xfail(using_string_dtype(), reason="can't fill 0 in string")
363362
@pytest.mark.parametrize(
364363
"categorical, numeric",
365364
[

pandas/tests/series/test_formats.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def test_tidy_repr_name_0(self, arg):
144144
assert "Name: 0" in rep_str
145145

146146
@pytest.mark.xfail(
147-
using_string_dtype(), reason="TODO: investigate why this is failing"
147+
using_string_dtype(), reason="TODO(infer_string): investigate failure"
148148
)
149149
def test_newline(self):
150150
ser = Series(["a\n\r\tb"], name="a\n\r\td", index=["a\n\r\tf"])

0 commit comments

Comments
 (0)