diff --git a/fsspec/implementations/local.py b/fsspec/implementations/local.py index b62eff8ce..202f6036e 100644 --- a/fsspec/implementations/local.py +++ b/fsspec/implementations/local.py @@ -315,6 +315,9 @@ def tell(self, *args, **kwargs): def seek(self, *args, **kwargs): return self.f.seek(*args, **kwargs) + def seekable(self, *args, **kwargs): + return self.f.seekable(*args, **kwargs) + def readline(self, *args, **kwargs): return self.f.readline(*args, **kwargs) diff --git a/fsspec/implementations/tests/test_local.py b/fsspec/implementations/tests/test_local.py index dbcdfb23d..389b8c133 100644 --- a/fsspec/implementations/tests/test_local.py +++ b/fsspec/implementations/tests/test_local.py @@ -724,3 +724,18 @@ def test_info_path_like(tmpdir): fs = LocalFileSystem() assert fs.exists(path) + + +def test_seekable(tmpdir): + fs = LocalFileSystem() + tmpdir = str(tmpdir) + fn0 = os.path.join(tmpdir, "target") + + with open(fn0, "wb") as f: + f.write(b"data") + + f = fs.open(fn0, "rt") + assert f.seekable(), "file is not seekable" + f.seek(1) + assert f.read(1) == "a" + assert f.tell() == 2 diff --git a/fsspec/implementations/tests/test_memory.py b/fsspec/implementations/tests/test_memory.py index 43059faa6..67902656b 100644 --- a/fsspec/implementations/tests/test_memory.py +++ b/fsspec/implementations/tests/test_memory.py @@ -138,3 +138,15 @@ def test_rm_reursive_empty_subdir(m): m.mkdir("recdir/subdir2") m.rm("recdir/", recursive=True) assert not m.exists("dir") + + +def test_seekable(m): + fn0 = "foo.txt" + with m.open(fn0, "wb") as f: + f.write(b"data") + + f = m.open(fn0, "rt") + assert f.seekable(), "file is not seekable" + f.seek(1) + assert f.read(1) == "a" + assert f.tell() == 2