Skip to content

Commit 1dadee6

Browse files
author
Martin Durant
committed
Coverage
1 parent 23bce67 commit 1dadee6

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

zarr/tests/test_storage.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,37 @@ def test_create(self):
879879
with pytest.raises(PermissionError):
880880
g.data[:] = 1
881881

882+
def test_read_only(self):
883+
path = tempfile.mkdtemp()
884+
atexit.register(atexit_rmtree, path)
885+
store = FSStore(path)
886+
store['foo'] = b"bar"
887+
888+
store = FSStore(path, mode='r')
889+
890+
with pytest.raises(PermissionError):
891+
store['foo'] = b"hex"
892+
893+
with pytest.raises(PermissionError):
894+
del store['foo']
895+
896+
with pytest.raises(PermissionError):
897+
store.clear()
898+
899+
with pytest.raises(PermissionError):
900+
store.rmdir("anydir")
901+
902+
assert store['foo'] == b"bar"
903+
904+
filepath = os.path.join(path, "foo")
905+
with pytest.raises(ValueError):
906+
FSStore(filepath, mode='r')
907+
908+
def test_eq(self):
909+
store1 = FSStore("anypath")
910+
store2 = FSStore("anypath")
911+
assert store1 == store2
912+
882913

883914
class TestNestedDirectoryStore(TestDirectoryStore, unittest.TestCase):
884915

0 commit comments

Comments
 (0)