Skip to content

Commit 8ef73d6

Browse files
WillAydrhshadrach
andauthored
Backport PR pandas-dev#60683: TST(string dtype): Resolve xfails in test_to_csv (pandas-dev#60687)
Co-authored-by: Richard Shadrach <[email protected]>
1 parent 65c1a54 commit 8ef73d6

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

pandas/tests/frame/methods/test_astype.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ def test_astype_tz_object_conversion(self, tz):
760760
result = result.astype({"tz": "datetime64[ns, Europe/London]"})
761761
tm.assert_frame_equal(result, expected)
762762

763-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
763+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string) GH#60639")
764764
def test_astype_dt64_to_string(
765765
self, frame_or_series, tz_naive_fixture, using_infer_string
766766
):

pandas/tests/frame/methods/test_reset_index.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ def test_rest_index_multiindex_categorical_with_missing_values(self, codes):
646646
tm.assert_frame_equal(res, expected)
647647

648648

649-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
649+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string) - GH#60338")
650650
@pytest.mark.parametrize(
651651
"array, dtype",
652652
[

pandas/tests/frame/methods/test_to_csv.py

+4-10
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
import numpy as np
66
import pytest
77

8-
from pandas._config import using_string_dtype
9-
108
from pandas.errors import ParserError
119

1210
import pandas as pd
@@ -422,20 +420,18 @@ def test_to_csv_empty(self):
422420
result, expected = self._return_result_expected(df, 1000)
423421
tm.assert_frame_equal(result, expected, check_column_type=False)
424422

425-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
426423
@pytest.mark.slow
427424
def test_to_csv_chunksize(self):
428425
chunksize = 1000
429426
rows = chunksize // 2 + 1
430427
df = DataFrame(
431428
np.ones((rows, 2)),
432-
columns=Index(list("ab"), dtype=object),
429+
columns=Index(list("ab")),
433430
index=MultiIndex.from_arrays([range(rows) for _ in range(2)]),
434431
)
435432
result, expected = self._return_result_expected(df, chunksize, rnlvl=2)
436433
tm.assert_frame_equal(result, expected, check_names=False)
437434

438-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
439435
@pytest.mark.slow
440436
@pytest.mark.parametrize(
441437
"nrows", [2, 10, 99, 100, 101, 102, 198, 199, 200, 201, 202, 249, 250, 251]
@@ -464,7 +460,7 @@ def test_to_csv_params(self, nrows, df_params, func_params, ncols):
464460
for _ in range(df_params["c_idx_nlevels"])
465461
)
466462
else:
467-
columns = Index([f"i-{i}" for i in range(ncols)], dtype=object)
463+
columns = Index([f"i-{i}" for i in range(ncols)])
468464
df = DataFrame(np.ones((nrows, ncols)), index=index, columns=columns)
469465
result, expected = self._return_result_expected(df, 1000, **func_params)
470466
tm.assert_frame_equal(result, expected, check_names=False)
@@ -722,7 +718,6 @@ def test_to_csv_withcommas(self):
722718
df2 = self.read_csv(path)
723719
tm.assert_frame_equal(df2, df)
724720

725-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
726721
def test_to_csv_mixed(self):
727722
def create_cols(name):
728723
return [f"{name}{i:03d}" for i in range(5)]
@@ -739,7 +734,7 @@ def create_cols(name):
739734
)
740735
df_bool = DataFrame(True, index=df_float.index, columns=create_cols("bool"))
741736
df_object = DataFrame(
742-
"foo", index=df_float.index, columns=create_cols("object")
737+
"foo", index=df_float.index, columns=create_cols("object"), dtype="object"
743738
)
744739
df_dt = DataFrame(
745740
Timestamp("20010101").as_unit("ns"),
@@ -812,13 +807,12 @@ def test_to_csv_dups_cols(self):
812807
result.columns = df.columns
813808
tm.assert_frame_equal(result, df)
814809

815-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
816810
def test_to_csv_dups_cols2(self):
817811
# GH3457
818812
df = DataFrame(
819813
np.ones((5, 3)),
820814
index=Index([f"i-{i}" for i in range(5)], name="foo"),
821-
columns=Index(["a", "a", "b"], dtype=object),
815+
columns=Index(["a", "a", "b"]),
822816
)
823817

824818
with tm.ensure_clean() as filename:

0 commit comments

Comments
 (0)