Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure DictStore contains only bytes #350

Merged
merged 8 commits into from
Dec 7, 2018
Prev Previous commit
Next Next commit
Check for TypeError for non-buffer objects
Add a test to ensure that a non-buffer supporting object when stored
into a valid store, will raise a `TypeError` instead of storing it.
Disable this checking for generic `MappingStore`s (e.g. `dict`) as they
do not perform this sort of checking on the data they accept as values.
jakirkham committed Dec 6, 2018
commit bc3fe3b0d974573b57c6f9309ba7df83dbb07f5f
10 changes: 10 additions & 0 deletions zarr/tests/test_storage.py
Original file line number Diff line number Diff line change
@@ -63,6 +63,12 @@ def test_get_set_del_contains(self):
# noinspection PyStatementEffect
del store['foo']

def test_set_invalid_content(self):
store = self.create_store()

with pytest.raises(TypeError):
store['baz'] = list(range(5))

def test_clear(self):
store = self.create_store()
store['foo'] = b'bar'
@@ -586,6 +592,10 @@ class TestMappingStore(StoreTests, unittest.TestCase):
def create_store(self):
return dict()

def test_set_invalid_content(self):
# Generic mappings support non-buffer types
pass


def setdel_hierarchy_checks(store):
# these tests are for stores that are aware of hierarchy levels; this