Skip to content

Commit 82c591d

Browse files
authored
Adjust test in excel folder for new string option (#56193)
1 parent 3fc8320 commit 82c591d

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

pandas/tests/io/excel/test_readers.py

+5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import numpy as np
1515
import pytest
1616

17+
from pandas._config import using_pyarrow_string_dtype
18+
1719
import pandas.util._test_decorators as td
1820

1921
import pandas as pd
@@ -637,6 +639,9 @@ def test_dtype_backend_and_dtype(self, read_ext):
637639
)
638640
tm.assert_frame_equal(result, df)
639641

642+
@pytest.mark.xfail(
643+
using_pyarrow_string_dtype(), reason="infer_string takes precedence"
644+
)
640645
def test_dtype_backend_string(self, read_ext, string_storage):
641646
# GH#36712
642647
if read_ext in (".xlsb", ".xls"):

pandas/tests/io/excel/test_writers.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ def test_excel_date_datetime_format(self, ext, path):
709709
# we need to use df_expected to check the result.
710710
tm.assert_frame_equal(rs2, df_expected)
711711

712-
def test_to_excel_interval_no_labels(self, path):
712+
def test_to_excel_interval_no_labels(self, path, using_infer_string):
713713
# see gh-19242
714714
#
715715
# Test writing Interval without labels.
@@ -719,7 +719,9 @@ def test_to_excel_interval_no_labels(self, path):
719719
expected = df.copy()
720720

721721
df["new"] = pd.cut(df[0], 10)
722-
expected["new"] = pd.cut(expected[0], 10).astype(str)
722+
expected["new"] = pd.cut(expected[0], 10).astype(
723+
str if not using_infer_string else "string[pyarrow_numpy]"
724+
)
723725

724726
df.to_excel(path, sheet_name="test1")
725727
with ExcelFile(path) as reader:
@@ -1213,10 +1215,9 @@ def test_render_as_column_name(self, path):
12131215

12141216
def test_true_and_false_value_options(self, path):
12151217
# see gh-13347
1216-
df = DataFrame([["foo", "bar"]], columns=["col1", "col2"])
1217-
msg = "Downcasting behavior in `replace`"
1218-
with tm.assert_produces_warning(FutureWarning, match=msg):
1219-
expected = df.replace({"foo": True, "bar": False})
1218+
df = DataFrame([["foo", "bar"]], columns=["col1", "col2"], dtype=object)
1219+
with option_context("future.no_silent_downcasting", True):
1220+
expected = df.replace({"foo": True, "bar": False}).astype("bool")
12201221

12211222
df.to_excel(path)
12221223
read_frame = pd.read_excel(

0 commit comments

Comments
 (0)