Skip to content

Commit f5ca683

Browse files
TST (string dtype): clean-up xpasssing tests with future string dtype (#59323)
1 parent 7ee3154 commit f5ca683

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
@@ -58,9 +58,7 @@ def test_from_records_with_datetimes(self):
5858
expected["EXPIRY"] = expected["EXPIRY"].astype("M8[s]")
5959
tm.assert_frame_equal(result, expected)
6060

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

pandas/tests/frame/methods/test_fillna.py

+2
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ def test_fillna_datetime(self, datetime_frame):
9191
with pytest.raises(ValueError, match=msg):
9292
datetime_frame.fillna(5, method="ffill")
9393

94+
# TODO(infer_string) test as actual error instead of xfail
9495
@pytest.mark.xfail(using_string_dtype(), reason="can't fill 0 in string")
9596
def test_fillna_mixed_type(self, float_string_frame):
9697
mf = float_string_frame
@@ -664,6 +665,7 @@ def test_fillna_col_reordering(self):
664665
filled = df.fillna(method="ffill")
665666
assert df.columns.tolist() == filled.columns.tolist()
666667

668+
# TODO(infer_string) test as actual error instead of xfail
667669
@pytest.mark.xfail(using_string_dtype(), reason="can't fill 0 in string")
668670
def test_fill_corner(self, float_frame, float_string_frame):
669671
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
@@ -69,6 +69,7 @@ def test_interpolate_inplace(self, frame_or_series, using_array_manager, request
6969
assert np.shares_memory(orig, obj.values)
7070
assert orig.squeeze()[1] == 1.5
7171

72+
# TODO(infer_string) raise proper TypeError in case of string dtype
7273
@pytest.mark.xfail(
7374
using_string_dtype(), reason="interpolate doesn't work for string"
7475
)

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.util._test_decorators as td
1715

1816
import pandas as pd
@@ -253,7 +251,6 @@ def test_timestamp_compare(self, left, right):
253251
with pytest.raises(TypeError, match=msg):
254252
right_f(pd.Timestamp("nat"), df)
255253

256-
@pytest.mark.xfail(using_string_dtype(), reason="can't compare string and int")
257254
def test_mixed_comparison(self):
258255
# GH#13128, GH#22163 != datetime64 vs non-dt64 should be False,
259256
# 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,
@@ -833,8 +831,6 @@ def replacer(self, how, from_key, to_key):
833831
raise ValueError
834832
return replacer
835833

836-
# Expected needs adjustment for the infer string option, seems to work as expecetd
837-
@pytest.mark.skipif(using_string_dtype(), reason="TODO: test is to complex")
838834
def test_replace_series(self, how, to_key, from_key, replacer):
839835
index = pd.Index([3, 4], name="xxx")
840836
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 (
@@ -461,7 +459,6 @@ def test_set_index_nan(self):
461459
)
462460
tm.assert_frame_equal(result, df)
463461

464-
@pytest.mark.xfail(using_string_dtype(), reason="can't multiply arrow strings")
465462
def test_multi_assign(self):
466463
# GH 3626, an assignment of a sub-df to a df
467464
# set float64 to avoid upcast when setting nan
@@ -687,7 +684,6 @@ def test_loc_setitem_fullindex_views(self):
687684
df.loc[df.index] = df.loc[df.index]
688685
tm.assert_frame_equal(df, df2)
689686

690-
@pytest.mark.xfail(using_string_dtype(), reason="can't set int into string")
691687
def test_rhs_alignment(self):
692688
# GH8258, tests that both rows & columns are aligned to what is
693689
# 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
import pandas.util._test_decorators as td
75

86
from pandas import (
@@ -24,7 +22,6 @@
2422
import pandas._testing as tm
2523

2624

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

pandas/tests/series/methods/test_replace.py

-1
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,6 @@ def test_replace_mixed_types_with_string(self):
391391
expected = pd.Series([1, np.nan, 3, np.nan, 4, 5])
392392
tm.assert_series_equal(expected, result)
393393

394-
@pytest.mark.xfail(using_string_dtype(), reason="can't fill 0 in string")
395394
@pytest.mark.parametrize(
396395
"categorical, numeric",
397396
[

pandas/tests/series/test_formats.py

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

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

0 commit comments

Comments
 (0)