@@ -56,7 +56,15 @@ def open(*args):
5656
5757 monkeypatch .setattr ("gcsfs.GCSFileSystem" , MockGCSFileSystem )
5858 df1 .to_csv ("gs://test/test.csv" , index = True )
59- df2 = read_csv (StringIO (s .getvalue ()), parse_dates = ["dt" ], index_col = 0 )
59+
60+ def mock_get_filepath_or_buffer (* args , ** kwargs ):
61+ return StringIO (df1 .to_csv ()), None , None , False
62+
63+ monkeypatch .setattr (
64+ "pandas.io.gcs.get_filepath_or_buffer" , mock_get_filepath_or_buffer
65+ )
66+
67+ df2 = read_csv ("gs://test/test.csv" , parse_dates = ["dt" ], index_col = 0 )
6068
6169 tm .assert_frame_equal (df1 , df2 )
6270
@@ -86,28 +94,6 @@ def open(self, path, mode="r", *args):
8694 )
8795
8896
89- @td .skip_if_no ("gcsfs" )
90- def test_gcs_get_filepath_or_buffer (monkeypatch ):
91- df1 = DataFrame (
92- {
93- "int" : [1 , 3 ],
94- "float" : [2.0 , np .nan ],
95- "str" : ["t" , "s" ],
96- "dt" : date_range ("2018-06-18" , periods = 2 ),
97- }
98- )
99-
100- def mock_get_filepath_or_buffer (* args , ** kwargs ):
101- return (StringIO (df1 .to_csv (index = False )), None , None , False )
102-
103- monkeypatch .setattr (
104- "pandas.io.gcs.get_filepath_or_buffer" , mock_get_filepath_or_buffer
105- )
106- df2 = read_csv ("gs://test/test.csv" , parse_dates = ["dt" ])
107-
108- tm .assert_frame_equal (df1 , df2 )
109-
110-
11197@td .skip_if_installed ("gcsfs" )
11298def test_gcs_not_present_exception ():
11399 with pytest .raises (ImportError ) as e :
0 commit comments