Skip to content

Commit f6c9f61

Browse files
author
Martin Durant
committed
Merge branch 'master' into cache-glob
2 parents c87d0c8 + 5b108b4 commit f6c9f61

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

fsspec/spec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,7 @@ def seek(self, loc, whence=0):
10371037
"""
10381038
loc = int(loc)
10391039
if not self.mode == "rb":
1040-
raise ValueError("Seek only available in read mode")
1040+
raise OSError("Seek only available in read mode")
10411041
if whence == 0:
10421042
nloc = loc
10431043
elif whence == 1:

fsspec/tests/test_file.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def test_file_write_attributes(ftp_writable):
105105
f = ftp.open("/out2", "wb")
106106
with pytest.raises(ValueError):
107107
f.info()
108-
with pytest.raises(ValueError):
108+
with pytest.raises(OSError):
109109
f.seek(0)
110110
with pytest.raises(ValueError):
111111
f.read(0)
@@ -175,3 +175,20 @@ def test_with_gzip(ftp_writable):
175175
with fs.open(fn, "rb") as f:
176176
gf = gzip.GzipFile(fileobj=f, mode="r")
177177
assert gf.read() == data
178+
179+
180+
def test_with_zip(ftp_writable):
181+
import zipfile
182+
183+
data = b"hello zip"
184+
host, port, user, pw = ftp_writable
185+
fs = FTPFileSystem(host=host, port=port, username=user, password=pw)
186+
fn = "/myfile.zip"
187+
inner_file = "test.txt"
188+
with fs.open(fn, "wb") as f:
189+
zf = zipfile.ZipFile(f, mode="w")
190+
zf.writestr(inner_file, data)
191+
zf.close()
192+
with fs.open(fn, "rb") as f:
193+
zf = zipfile.ZipFile(f, mode="r")
194+
assert zf.read(inner_file) == data

0 commit comments

Comments
 (0)