Skip to content

Commit ea45a3f

Browse files
committed
Add test
1 parent b971911 commit ea45a3f

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

fsspec/tests/test_spec.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
from fsspec.implementations.local import LocalFileSystem
1717
from fsspec.spec import AbstractBufferedFile, AbstractFileSystem
1818

19+
from fsspec.tests.conftest import data, server
20+
1921
PATHS_FOR_GLOB_TESTS = (
2022
{"name": "test0.json", "type": "file", "size": 100},
2123
{"name": "test0.yaml", "type": "file", "size": 100},
@@ -744,6 +746,26 @@ def test_cache():
744746
assert len(DummyTestFS._cache) == 0
745747

746748

749+
def test_cache_not_pickled(server):
750+
fs = fsspec.filesystem("http")
751+
filepath = server.realfile
752+
length = 3
753+
f = fs.open(filepath, mode="rb")
754+
assert not f.cache.cache # No cache initially
755+
assert f.read(length=length) == data[:length]
756+
assert f.cache.cache == data # Cache is populated
757+
758+
# Roundtrip through pickle
759+
import pickle
760+
761+
f2 = pickle.loads(pickle.dumps(f))
762+
assert not f2.cache.cache # No cache initially
763+
assert (
764+
f2.read(length=length) == data[length : 2 * length]
765+
) # Read file from previous seek point
766+
assert f2.cache.cache == data[length:] # Cache is populated
767+
768+
747769
def test_current():
748770
fs = DummyTestFS()
749771
fs2 = DummyTestFS(arg=1)

0 commit comments

Comments
 (0)