Skip to content

Commit 03b88cb

Browse files
lithomas1pooja-subramaniam
authored andcommitted
TST: Remove fsspec internals from tests (pandas-dev#50925)
1 parent ab7e853 commit 03b88cb

File tree

2 files changed

+5
-21
lines changed

2 files changed

+5
-21
lines changed

pandas/tests/io/test_fsspec.py

-2
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,8 @@ def test_read_csv(cleared_fs, df1):
5050

5151

5252
def test_reasonable_error(monkeypatch, cleared_fs):
53-
from fsspec import registry
5453
from fsspec.registry import known_implementations
5554

56-
registry.target.clear()
5755
with pytest.raises(ValueError, match="nosuchprotocol"):
5856
read_csv("nosuchprotocol://test/test.csv")
5957
err_msg = "test error message"

pandas/tests/io/test_gcs.py

+5-19
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,12 @@
2222
@pytest.fixture
2323
def gcs_buffer(monkeypatch):
2424
"""Emulate GCS using a binary buffer."""
25-
from fsspec import (
26-
AbstractFileSystem,
27-
registry,
28-
)
29-
30-
registry.target.clear() # remove state
25+
import fsspec
3126

3227
gcs_buffer = BytesIO()
3328
gcs_buffer.close = lambda: True
3429

35-
class MockGCSFileSystem(AbstractFileSystem):
30+
class MockGCSFileSystem(fsspec.AbstractFileSystem):
3631
@staticmethod
3732
def open(*args, **kwargs):
3833
gcs_buffer.seek(0)
@@ -42,7 +37,8 @@ def ls(self, path, **kwargs):
4237
# needed for pyarrow
4338
return [{"name": path, "type": "file"}]
4439

45-
monkeypatch.setattr("gcsfs.GCSFileSystem", MockGCSFileSystem)
40+
# Overwrites the default implementation from gcsfs to our mock class
41+
fsspec.register_implementation("gs", MockGCSFileSystem, clobber=True)
4642

4743
return gcs_buffer
4844

@@ -55,9 +51,6 @@ def test_to_read_gcs(gcs_buffer, format):
5551
5652
GH 33987
5753
"""
58-
from fsspec import registry
59-
60-
registry.target.clear() # remove state
6154

6255
df1 = DataFrame(
6356
{
@@ -132,9 +125,6 @@ def test_to_csv_compression_encoding_gcs(gcs_buffer, compression_only, encoding)
132125
GH 35677 (to_csv, compression), GH 26124 (to_csv, encoding), and
133126
GH 32392 (read_csv, encoding)
134127
"""
135-
from fsspec import registry
136-
137-
registry.target.clear() # remove state
138128
df = tm.makeDataFrame()
139129

140130
# reference of compressed and encoded file
@@ -174,12 +164,8 @@ def test_to_csv_compression_encoding_gcs(gcs_buffer, compression_only, encoding)
174164
@td.skip_if_no("gcsfs")
175165
def test_to_parquet_gcs_new_file(monkeypatch, tmpdir):
176166
"""Regression test for writing to a not-yet-existent GCS Parquet file."""
177-
from fsspec import (
178-
AbstractFileSystem,
179-
registry,
180-
)
167+
from fsspec import AbstractFileSystem
181168

182-
registry.target.clear() # remove state
183169
df1 = DataFrame(
184170
{
185171
"int": [1, 3],

0 commit comments

Comments
 (0)