def create_store(): path = tempfile.mktemp(suffix='.lmdb') atexit_rmtree(path) try: store = LMDBStore(path) except ImportError: # pragma: no cover raise SkipTest('lmdb nod installed') return store, None
def create_array(read_only=False, **kwargs): path = mktemp(suffix='.lmdb') atexit_rmtree(path) try: store = LMDBStore(path, buffers=False) except ImportError: # pragma: no cover raise SkipTest('lmdb not installed') kwargs.setdefault('compressor', Zlib(1)) init_array(store, **kwargs) return Array(store, read_only=read_only)
def create_store(self): path = tempfile.mktemp(suffix='.lmdb') atexit_rmtree(path) if PY2: # pragma: py3 no cover # don't use buffers, otherwise would have to rewrite tests as bytes and # buffer don't compare equal in PY2 buffers = False else: # pragma: py2 no cover buffers = True try: store = LMDBStore(path, buffers=buffers) except ImportError: # pragma: no cover raise SkipTest('lmdb not installed') return store
def test_open_group(): store = tempfile.mkdtemp() atexit_rmtree(store) # open group, create if doesn't exist g = open(store, mode='a') g.create_group('foo') assert isinstance(g, Group) assert 'foo' in g # open group, overwrite g = open(store, mode='w') assert isinstance(g, Group) assert 'foo' not in g # open group, read-only g = open(store, mode='r') assert isinstance(g, Group) assert g.read_only
def test_open_array(): store = tempfile.mkdtemp() atexit_rmtree(store) # open array, create if doesn't exist z = open(store, mode='a', shape=100) assert isinstance(z, Array) assert z.shape == (100, ) # open array, overwrite z = open(store, mode='w', shape=200) assert isinstance(z, Array) assert z.shape == (200, ) # open array, read-only z = open(store, mode='r') assert isinstance(z, Array) assert z.shape == (200, ) assert z.read_only # path not found with assert_raises(ValueError): open('doesnotexist', mode='r')