Traktor/myenv/Lib/site-packages/fsspec/implementations/tests/test_dask.py

30 lines
573 B
Python
Raw Normal View History

2024-05-26 05:12:46 +02:00
import pytest
import fsspec
pytest.importorskip("distributed")
@pytest.fixture()
def cli(tmpdir):
import dask.distributed
client = dask.distributed.Client(n_workers=1)
def setup():
m = fsspec.filesystem("memory")
with m.open("afile", "wb") as f:
f.write(b"data")
client.run(setup)
try:
yield client
finally:
client.shutdown()
def test_basic(cli):
fs = fsspec.filesystem("dask", target_protocol="memory")
assert fs.ls("", detail=False) == ["/afile"]
assert fs.cat("/afile") == b"data"