Skip to content

Commit fd9d8e8

Browse files
committed
add test for r+b
1 parent 637a4f3 commit fd9d8e8

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/test_basicio.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,25 @@ def test_write_fsspec(localserver, clear_server):
183183
assert f.read() == TESTDATA1
184184

185185

186+
def test_write_rpb_fsspec(localserver, clear_server):
187+
"""Test writing with r+b as in uproot"""
188+
remoteurl, localpath = localserver
189+
fs, _ = fsspec.core.url_to_fs(remoteurl)
190+
filename = "test.bin"
191+
fs.touch(localpath + "/" + filename)
192+
with fsspec.open(remoteurl + "/" + filename, "r+b") as f:
193+
f.write(b'Hello, this is a test file for r+b mode.')
194+
f.flush()
195+
with fsspec.open(remoteurl + "/" + filename, "r+b") as f:
196+
assert f.read() == b'Hello, this is a test file for r+b mode.'
197+
with fsspec.open(remoteurl + "/" + filename, "r+b") as f:
198+
f.seek(len(b'Hello, this is a '))
199+
f.write(b'REPLACED ')
200+
f.flush()
201+
with fsspec.open(remoteurl + "/" + filename, "r+b") as f:
202+
assert f.read() == b'Hello, this is a REPLACED for r+b mode.'
203+
204+
186205
@pytest.mark.parametrize("start, end", [(None, None), (None, 10), (1, None), (1, 10)])
187206
def test_read_bytes_fsspec(localserver, clear_server, start, end):
188207
remoteurl, localpath = localserver

0 commit comments

Comments
 (0)