@@ -56,7 +56,15 @@ def open(*args):
56
56
57
57
monkeypatch .setattr ("gcsfs.GCSFileSystem" , MockGCSFileSystem )
58
58
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 )
60
68
61
69
tm .assert_frame_equal (df1 , df2 )
62
70
@@ -86,28 +94,6 @@ def open(self, path, mode="r", *args):
86
94
)
87
95
88
96
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
-
111
97
@td .skip_if_installed ("gcsfs" )
112
98
def test_gcs_not_present_exception ():
113
99
with pytest .raises (ImportError ) as e :
0 commit comments