Skip to content

Adjust test in excel folder for new string option #56193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pandas/tests/io/excel/test_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import numpy as np
import pytest

from pandas._config import using_pyarrow_string_dtype

import pandas.util._test_decorators as td

import pandas as pd
Expand Down Expand Up @@ -637,6 +639,9 @@ def test_dtype_backend_and_dtype(self, read_ext):
)
tm.assert_frame_equal(result, df)

@pytest.mark.xfail(
using_pyarrow_string_dtype(), reason="infer_string takes precedence"
)
def test_dtype_backend_string(self, read_ext, string_storage):
# GH#36712
if read_ext in (".xlsb", ".xls"):
Expand Down
13 changes: 7 additions & 6 deletions pandas/tests/io/excel/test_writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ def test_excel_date_datetime_format(self, ext, path):
# we need to use df_expected to check the result.
tm.assert_frame_equal(rs2, df_expected)

def test_to_excel_interval_no_labels(self, path):
def test_to_excel_interval_no_labels(self, path, using_infer_string):
# see gh-19242
#
# Test writing Interval without labels.
Expand All @@ -719,7 +719,9 @@ def test_to_excel_interval_no_labels(self, path):
expected = df.copy()

df["new"] = pd.cut(df[0], 10)
expected["new"] = pd.cut(expected[0], 10).astype(str)
expected["new"] = pd.cut(expected[0], 10).astype(
str if not using_infer_string else "string[pyarrow_numpy]"
)

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

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

df.to_excel(path)
read_frame = pd.read_excel(
Expand Down