Skip to content

Commit a889ebf

Browse files
committed
xfail everything
1 parent f988f0d commit a889ebf

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

pandas/tests/io/formats/test_to_csv.py

+42-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,22 @@ def engine(request):
2121
return request.param
2222

2323

24+
@pytest.fixture
25+
def pyarrow_xfail(request):
26+
"""
27+
Fixture that xfails a test if the engine is pyarrow.
28+
"""
29+
engine = request.getfixturevalue("engine")
30+
if engine == "pyarrow":
31+
mark = pytest.mark.xfail(reason="pyarrow doesn't support this.")
32+
request.node.add_marker(mark)
33+
34+
35+
xfail_pyarrow = pytest.mark.usefixtures("pyarrow_xfail")
36+
37+
2438
class TestToCSV:
39+
@xfail_pyarrow
2540
def test_to_csv_with_single_column(self, engine):
2641
# see gh-18676, https://bugs.python.org/issue32255
2742
#
@@ -59,6 +74,7 @@ def test_to_csv_default_encoding(self, engine):
5974
df.to_csv(path, engine=engine)
6075
tm.assert_frame_equal(pd.read_csv(path, index_col=0), df)
6176

77+
@xfail_pyarrow
6278
def test_to_csv_quotechar(self, engine):
6379
df = DataFrame({"col": [1, 2]})
6480
expected = """\
@@ -131,12 +147,14 @@ def test_to_csv_escapechar(self, engine=engine):
131147
with open(path, encoding="utf-8") as f:
132148
assert f.read() == expected
133149

150+
@xfail_pyarrow
134151
def test_csv_to_string(self, engine):
135152
df = DataFrame({"col": [1, 2]})
136153
expected_rows = [",col", "0,1", "1,2"]
137154
expected = tm.convert_rows_list_to_csv_str(expected_rows)
138155
assert df.to_csv(engine=engine) == expected
139156

157+
@xfail_pyarrow
140158
def test_to_csv_decimal(self, engine):
141159
# see gh-781
142160
df = DataFrame({"col1": [1], "col2": ["a"], "col3": [10.1]})
@@ -176,7 +194,8 @@ def test_to_csv_decimal(self, engine):
176194
# same for a multi-index
177195
assert df.set_index(["a", "b"]).to_csv(engine=engine, decimal="^") == expected
178196

179-
def test_to_csv_float_format(self):
197+
@xfail_pyarrow
198+
def test_to_csv_float_format(self, engine):
180199
# testing if float_format is taken into account for the index
181200
# GH 11553
182201
df = DataFrame({"a": [0, 1], "b": [2.2, 3.3], "c": 1})
@@ -191,7 +210,8 @@ def test_to_csv_float_format(self):
191210
== expected
192211
)
193212

194-
def test_to_csv_na_rep(self):
213+
@xfail_pyarrow
214+
def test_to_csv_na_rep(self, engine):
195215
# see gh-11553
196216
#
197217
# Testing if NaN values are correctly represented in the index.
@@ -222,6 +242,7 @@ def test_to_csv_na_rep(self):
222242
expected = tm.convert_rows_list_to_csv_str([",0", "0,a", "1,ZZZZZ", "2,c"])
223243
assert expected == csv
224244

245+
@xfail_pyarrow
225246
def test_to_csv_na_rep_nullable_string(self, nullable_string_dtype, engine):
226247
# GH 29975
227248
# Make sure full na_rep shows up when a dtype is provided
@@ -231,6 +252,7 @@ def test_to_csv_na_rep_nullable_string(self, nullable_string_dtype, engine):
231252
)
232253
assert expected == csv
233254

255+
@xfail_pyarrow
234256
def test_to_csv_date_format(self, engine):
235257
# GH 10209
236258
df_sec = DataFrame({"A": pd.date_range("20130101", periods=5, freq="s")})
@@ -302,6 +324,7 @@ def test_to_csv_date_format(self, engine):
302324
== expected_ymd_sec
303325
)
304326

327+
@xfail_pyarrow
305328
def test_to_csv_different_datetime_formats(self, engine):
306329
# GH#21734
307330
df = DataFrame(
@@ -318,6 +341,7 @@ def test_to_csv_different_datetime_formats(self, engine):
318341
expected = tm.convert_rows_list_to_csv_str(expected_rows)
319342
assert df.to_csv(index=False, engine=engine) == expected
320343

344+
@xfail_pyarrow
321345
def test_to_csv_date_format_in_categorical(self, engine):
322346
# GH#40754
323347
ser = pd.Series(pd.to_datetime(["2021-03-27", pd.NaT], format="%Y-%m-%d"))
@@ -335,6 +359,7 @@ def test_to_csv_date_format_in_categorical(self, engine):
335359
ser.to_csv(index=False, engine=engine, date_format="%Y-%m-%d") == expected
336360
)
337361

362+
@xfail_pyarrow
338363
def test_to_csv_float_ea_float_format(self, engine):
339364
# GH#45991
340365
df = DataFrame({"a": [1.1, 2.02, pd.NA, 6.000006], "b": "c"})
@@ -345,6 +370,7 @@ def test_to_csv_float_ea_float_format(self, engine):
345370
)
346371
assert result == expected
347372

373+
@xfail_pyarrow
348374
def test_to_csv_float_ea_no_float_format(self, engine):
349375
# GH#45991
350376
df = DataFrame({"a": [1.1, 2.02, pd.NA, 6.000006], "b": "c"})
@@ -355,6 +381,7 @@ def test_to_csv_float_ea_no_float_format(self, engine):
355381
)
356382
assert result == expected
357383

384+
@xfail_pyarrow
358385
def test_to_csv_multi_index(self, engine):
359386
# see gh-6618
360387
df = DataFrame([1], columns=pd.MultiIndex.from_arrays([[1], [2]]))
@@ -391,6 +418,7 @@ def test_to_csv_multi_index(self, engine):
391418
exp = tm.convert_rows_list_to_csv_str(exp_rows)
392419
assert df.to_csv(index=False, engine=engine) == exp
393420

421+
@xfail_pyarrow
394422
@pytest.mark.parametrize(
395423
"ind,expected",
396424
[
@@ -415,6 +443,7 @@ def test_to_csv_single_level_multi_index(
415443
result = obj.to_csv(lineterminator="\n", header=True, engine=engine)
416444
assert result == expected
417445

446+
@xfail_pyarrow
418447
def test_to_csv_string_array_ascii(self, engine):
419448
# GH 10813
420449
str_array = [{"names": ["foo", "bar"]}, {"names": ["baz", "qux"]}]
@@ -429,6 +458,7 @@ def test_to_csv_string_array_ascii(self, engine):
429458
with open(path, encoding="utf-8") as f:
430459
assert f.read() == expected_ascii
431460

461+
@xfail_pyarrow
432462
def test_to_csv_string_array_utf8(self, engine):
433463
# GH 10813
434464
str_array = [{"names": ["foo", "bar"]}, {"names": ["baz", "qux"]}]
@@ -443,6 +473,7 @@ def test_to_csv_string_array_utf8(self, engine):
443473
with open(path, encoding="utf-8") as f:
444474
assert f.read() == expected_utf8
445475

476+
@xfail_pyarrow
446477
def test_to_csv_string_with_lf(self, engine):
447478
# GH 20353
448479
data = {"int": [1, 2, 3], "str_lf": ["abc", "d\nef", "g\nh\n\ni"]}
@@ -477,6 +508,7 @@ def test_to_csv_string_with_lf(self, engine):
477508
with open(path, "rb") as f:
478509
assert f.read() == expected_crlf
479510

511+
@xfail_pyarrow
480512
def test_to_csv_string_with_crlf(self, engine):
481513
# GH 20353
482514
data = {"int": [1, 2, 3], "str_crlf": ["abc", "d\r\nef", "g\r\nh\r\n\r\ni"]}
@@ -516,6 +548,7 @@ def test_to_csv_string_with_crlf(self, engine):
516548
with open(path, "rb") as f:
517549
assert f.read() == expected_crlf
518550

551+
@xfail_pyarrow
519552
def test_to_csv_stdout_file(self, capsys, engine):
520553
# GH 21561
521554
df = DataFrame([["foo", "bar"], ["baz", "qux"]], columns=["name_1", "name_2"])
@@ -528,6 +561,7 @@ def test_to_csv_stdout_file(self, capsys, engine):
528561
assert captured.out == expected_ascii
529562
assert not sys.stdout.closed
530563

564+
@xfail_pyarrow
531565
@pytest.mark.xfail(
532566
compat.is_platform_windows(),
533567
reason=(
@@ -553,6 +587,7 @@ def test_to_csv_write_to_open_file(self, engine):
553587
with open(path, encoding="utf-8") as f:
554588
assert f.read() == expected
555589

590+
@xfail_pyarrow
556591
def test_to_csv_write_to_open_file_with_newline_py3(self, engine):
557592
# see gh-21696
558593
# see gh-20353
@@ -651,6 +686,7 @@ def test_to_csv_zip_infer_name(self, tmp_path, filename, expected_arcname, engin
651686
archived_file = zp.filelist[0].filename
652687
assert archived_file == expected_arcname
653688

689+
@xfail_pyarrow
654690
@pytest.mark.parametrize("df_new_type", ["Int64"])
655691
def test_to_csv_na_rep_long_string(self, df_new_type, engine):
656692
# see gh-25099
@@ -665,6 +701,7 @@ def test_to_csv_na_rep_long_string(self, df_new_type, engine):
665701

666702
assert expected == result
667703

704+
@xfail_pyarrow
668705
def test_to_csv_timedelta_precision(self, engine):
669706
# GH 6783
670707
s = pd.Series([1, 1]).astype("timedelta64[ns]")
@@ -679,6 +716,7 @@ def test_to_csv_timedelta_precision(self, engine):
679716
expected = tm.convert_rows_list_to_csv_str(expected_rows)
680717
assert result == expected
681718

719+
@xfail_pyarrow
682720
def test_na_rep_truncated(self, engine):
683721
# https://github.com/pandas-dev/pandas/issues/31447
684722
result = pd.Series(range(8, 12)).to_csv(na_rep="-", engine=engine)
@@ -693,6 +731,7 @@ def test_na_rep_truncated(self, engine):
693731
expected = tm.convert_rows_list_to_csv_str([",0", "0,1.1", "1,2.2"])
694732
assert result == expected
695733

734+
@xfail_pyarrow
696735
@pytest.mark.parametrize("errors", ["surrogatepass", "ignore", "replace"])
697736
def test_to_csv_errors(self, errors, engine):
698737
# GH 22610
@@ -717,6 +756,7 @@ def test_to_csv_binary_handle(self, mode, engine):
717756
df.to_csv(handle, mode=mode, engine=engine)
718757
tm.assert_frame_equal(df, pd.read_csv(path, index_col=0))
719758

759+
@xfail_pyarrow
720760
@pytest.mark.parametrize("mode", ["wb", "w"])
721761
def test_to_csv_encoding_binary_handle(self, mode, engine):
722762
"""

0 commit comments

Comments
 (0)