Skip to content

Commit ab4ce24

Browse files
committed
Add test for Parquet GCS write
1 parent 8974b50 commit ab4ce24

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

pandas/tests/io/test_gcs.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
from io import StringIO
23

34
import numpy as np
@@ -60,6 +61,29 @@ def open(*args):
6061
assert_frame_equal(df1, df2)
6162

6263

64+
@td.skip_if_no("gcsfs")
65+
def test_to_parquet_gcs_new_file(monkeypatch, tmpdir):
66+
"""Regression test for writing to a not-yet-existent GCS Parquet file."""
67+
df1 = DataFrame(
68+
{
69+
"int": [1, 3],
70+
"float": [2.0, np.nan],
71+
"str": ["t", "s"],
72+
"dt": date_range("2018-06-18", periods=2),
73+
}
74+
)
75+
76+
class MockGCSFileSystem:
77+
def open(self, path, mode='r', *args):
78+
if 'w' not in mode:
79+
raise FileNotFoundError
80+
return open(os.path.join(tmpdir, 'test.parquet'), mode)
81+
82+
monkeypatch.setattr("gcsfs.GCSFileSystem", MockGCSFileSystem)
83+
df1.to_parquet("gs://test/test.csv", index=True, engine='fastparquet',
84+
compression=None)
85+
86+
6387
@td.skip_if_no("gcsfs")
6488
def test_gcs_get_filepath_or_buffer(monkeypatch):
6589
df1 = DataFrame(

0 commit comments

Comments
 (0)