Skip to content

Commit c74b6d2

Browse files
update tests
1 parent 2ce0f67 commit c74b6d2

File tree

8 files changed

+19
-12
lines changed

8 files changed

+19
-12
lines changed

pandas/tests/arithmetic/test_object.py

+4
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ def test_objarr_add_invalid(self, op, box_with_array):
183183
"unsupported operand type",
184184
"must be str",
185185
"has no kernel",
186+
"operation 'add' not supported",
187+
"operation 'radd' not supported",
188+
"operation 'sub' not supported",
189+
"operation 'rsub' not supported",
186190
]
187191
)
188192
with pytest.raises(Exception, match=msg):

pandas/tests/groupby/methods/test_describe.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def test_series_describe_as_index(as_index, keys):
7171
tm.assert_frame_equal(result, expected)
7272

7373

74-
def test_frame_describe_multikey(tsframe):
74+
def test_frame_describe_multikey(tsframe, using_infer_string):
7575
grouped = tsframe.groupby([lambda x: x.year, lambda x: x.month])
7676
result = grouped.describe()
7777
desc_groups = []
@@ -87,6 +87,10 @@ def test_frame_describe_multikey(tsframe):
8787
expected = pd.concat(desc_groups, axis=1)
8888
tm.assert_frame_equal(result, expected)
8989

90+
# remainder of the tests fails with string dtype but is testing deprecated behaviour
91+
if using_infer_string:
92+
return
93+
9094
msg = "DataFrame.groupby with axis=1 is deprecated"
9195
with tm.assert_produces_warning(FutureWarning, match=msg):
9296
groupedT = tsframe.groupby({"A": 0, "B": 0, "C": 1, "D": 1}, axis=1)

pandas/tests/groupby/test_numeric_only.py

+1
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ def test_axis1_numeric_only(request, groupby_func, numeric_only, using_infer_str
273273
# cumsum, diff, pct_change
274274
"unsupported operand type",
275275
"has no kernel",
276+
"operation 'sub' not supported for dtype 'str' with dtype 'float64'",
276277
)
277278
if using_infer_string:
278279
pa = pytest.importorskip("pyarrow")

pandas/tests/groupby/transform/test_transform.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ def test_transform_nuisance_raises(df, using_infer_string):
513513
msg = "Could not convert"
514514
if using_infer_string:
515515
if df.columns.dtype.storage == "pyarrow":
516-
msg = "with dtype str does not support operation 'mean'"
516+
msg = "with dtype str does not support reduction 'mean'"
517517
else:
518518
msg = "Cannot perform reduction 'mean' with string dtype"
519519
with pytest.raises(TypeError, match=msg):
@@ -621,7 +621,7 @@ def test_groupby_transform_with_int(using_infer_string):
621621
msg = "Could not convert"
622622
if using_infer_string:
623623
if HAS_PYARROW:
624-
msg = "with dtype str does not support operation 'mean'"
624+
msg = "with dtype str does not support reduction 'mean'"
625625
else:
626626
msg = "Cannot perform reduction 'mean' with string dtype"
627627
with np.errstate(all="ignore"):

pandas/tests/indexing/test_iloc.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1221,7 +1221,9 @@ def test_iloc_setitem_multicolumn_to_datetime(self, using_infer_string):
12211221
df = DataFrame({"A": ["2022-01-01", "2022-01-02"], "B": ["2021", "2022"]})
12221222

12231223
if using_infer_string:
1224-
with pytest.raises(TypeError, match="Invalid value"):
1224+
with tm.assert_produces_warning(
1225+
FutureWarning, match="Setting an item of incompatible dtype"
1226+
):
12251227
df.iloc[:, [0]] = DataFrame({"A": to_datetime(["2021", "2022"])})
12261228
else:
12271229
df.iloc[:, [0]] = DataFrame({"A": to_datetime(["2021", "2022"])})

pandas/tests/indexing/test_loc.py

-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from pandas._config import using_string_dtype
1717

1818
from pandas._libs import index as libindex
19-
from pandas.compat import HAS_PYARROW
2019
from pandas.compat.numpy import np_version_gt2
2120
from pandas.errors import IndexingError
2221
import pandas.util._test_decorators as td
@@ -1459,9 +1458,6 @@ def test_loc_setitem_listlike_with_timedelta64index(self, indexer, expected):
14591458

14601459
tm.assert_frame_equal(expected, df)
14611460

1462-
@pytest.mark.xfail(
1463-
using_string_dtype() and not HAS_PYARROW, reason="TODO(infer_string)"
1464-
)
14651461
def test_loc_setitem_categorical_values_partial_column_slice(self):
14661462
# Assigning a Category to parts of a int/... column uses the values of
14671463
# the Categorical

pandas/tests/io/test_feather.py

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

5-
from pandas._config import using_string_dtype
6-
75
import pandas as pd
86
import pandas._testing as tm
97

@@ -148,7 +146,6 @@ def test_path_localpath(self):
148146
result = tm.round_trip_localpath(df.to_feather, read_feather)
149147
tm.assert_frame_equal(df, result)
150148

151-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
152149
def test_passthrough_keywords(self):
153150
df = pd.DataFrame(
154151
1.1 * np.arange(120).reshape((30, 4)),

pandas/tests/reshape/test_melt.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1199,7 +1199,10 @@ def test_raise_of_column_name_value(self):
11991199
):
12001200
df.melt(id_vars="value", value_name="value")
12011201

1202-
def test_missing_stubname(self, any_string_dtype):
1202+
def test_missing_stubname(self, request, any_string_dtype, using_infer_string):
1203+
if using_infer_string and any_string_dtype == "object":
1204+
# triggers object dtype inference warning of dtype=object
1205+
request.applymarker(pytest.mark.xfail(reason="TODO(infer_string)"))
12031206
# GH46044
12041207
df = DataFrame({"id": ["1", "2"], "a-1": [100, 200], "a-2": [300, 400]})
12051208
df = df.astype({"id": any_string_dtype})

0 commit comments

Comments
 (0)