Skip to content

TST: Remove fsspec internals from tests #50925

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions pandas/tests/io/test_fsspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,8 @@ def test_read_csv(cleared_fs, df1):


def test_reasonable_error(monkeypatch, cleared_fs):
from fsspec import registry
from fsspec.registry import known_implementations

registry.target.clear()
with pytest.raises(ValueError, match="nosuchprotocol"):
read_csv("nosuchprotocol://test/test.csv")
err_msg = "test error message"
Expand Down
24 changes: 5 additions & 19 deletions pandas/tests/io/test_gcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,12 @@
@pytest.fixture
def gcs_buffer(monkeypatch):
"""Emulate GCS using a binary buffer."""
from fsspec import (
AbstractFileSystem,
registry,
)

registry.target.clear() # remove state
import fsspec

gcs_buffer = BytesIO()
gcs_buffer.close = lambda: True

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

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

return gcs_buffer

Expand All @@ -55,9 +51,6 @@ def test_to_read_gcs(gcs_buffer, format):

GH 33987
"""
from fsspec import registry

registry.target.clear() # remove state

df1 = DataFrame(
{
Expand Down Expand Up @@ -132,9 +125,6 @@ def test_to_csv_compression_encoding_gcs(gcs_buffer, compression_only, encoding)
GH 35677 (to_csv, compression), GH 26124 (to_csv, encoding), and
GH 32392 (read_csv, encoding)
"""
from fsspec import registry

registry.target.clear() # remove state
df = tm.makeDataFrame()

# reference of compressed and encoded file
Expand Down Expand Up @@ -174,12 +164,8 @@ def test_to_csv_compression_encoding_gcs(gcs_buffer, compression_only, encoding)
@td.skip_if_no("gcsfs")
def test_to_parquet_gcs_new_file(monkeypatch, tmpdir):
"""Regression test for writing to a not-yet-existent GCS Parquet file."""
from fsspec import (
AbstractFileSystem,
registry,
)
from fsspec import AbstractFileSystem

registry.target.clear() # remove state
df1 = DataFrame(
{
"int": [1, 3],
Expand Down