Skip to content

Commit ecd9590

Browse files
committed
fix test atexit
1 parent 43523a4 commit ecd9590

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

zarr/tests/test_convenience.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import absolute_import, print_function, division
33
import tempfile
4+
import atexit
45

56

67
from nose.tools import assert_raises
@@ -17,7 +18,7 @@
1718
def test_open_array():
1819

1920
store = tempfile.mkdtemp()
20-
atexit_rmtree(store)
21+
atexit.register(atexit_rmtree, store)
2122

2223
# open array, create if doesn't exist
2324
z = open(store, mode='a', shape=100)
@@ -43,7 +44,7 @@ def test_open_array():
4344
def test_open_group():
4445

4546
store = tempfile.mkdtemp()
46-
atexit_rmtree(store)
47+
atexit.register(atexit_rmtree, store)
4748

4849
# open group, create if doesn't exist
4950
g = open(store, mode='a')

zarr/tests/test_core.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717

1818
from zarr.storage import (DirectoryStore, init_array, init_group, NestedDirectoryStore,
19-
DBMStore, LMDBStore, atexit_rmtree)
19+
DBMStore, LMDBStore, atexit_rmtree, atexit_rmglob)
2020
from zarr.core import Array
2121
from zarr.errors import PermissionError
2222
from zarr.compat import PY2
@@ -933,8 +933,8 @@ class TestArrayWithDBMStore(TestArray):
933933

934934
@staticmethod
935935
def create_array(read_only=False, **kwargs):
936-
path = mktemp(suffix='.dbm')
937-
atexit.register(os.remove, path)
936+
path = mktemp(suffix='.anydbm')
937+
atexit.register(atexit_rmglob, path + '*')
938938
store = DBMStore(path, flag='n')
939939
kwargs.setdefault('compressor', Zlib(1))
940940
init_array(store, **kwargs)
@@ -970,7 +970,7 @@ class TestArrayWithLMDBStore(TestArray):
970970
@staticmethod
971971
def create_array(read_only=False, **kwargs):
972972
path = mktemp(suffix='.lmdb')
973-
atexit_rmtree(path)
973+
atexit.register(atexit_rmtree, path)
974974
try:
975975
store = LMDBStore(path, buffers=True)
976976
except ImportError: # pragma: no cover
@@ -988,7 +988,7 @@ class TestArrayWithLMDBStoreNoBuffers(TestArray):
988988
@staticmethod
989989
def create_array(read_only=False, **kwargs):
990990
path = mktemp(suffix='.lmdb')
991-
atexit_rmtree(path)
991+
atexit.register(atexit_rmtree, path)
992992
try:
993993
store = LMDBStore(path, buffers=False)
994994
except ImportError: # pragma: no cover

zarr/tests/test_hierarchy.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
from zarr.storage import (DictStore, DirectoryStore, ZipStore, init_group, init_array,
2121
array_meta_key, group_meta_key, atexit_rmtree,
22-
NestedDirectoryStore, DBMStore, LMDBStore)
22+
NestedDirectoryStore, DBMStore, LMDBStore, atexit_rmglob)
2323
from zarr.core import Array
2424
from zarr.compat import PY2, text_type
2525
from zarr.hierarchy import Group, group, open_group
@@ -884,8 +884,8 @@ class TestGroupWithDBMStore(TestGroup):
884884

885885
@staticmethod
886886
def create_store():
887-
path = tempfile.mktemp(suffix='.dbm')
888-
atexit.register(os.remove, path)
887+
path = tempfile.mktemp(suffix='.anydbm')
888+
atexit.register(atexit_rmglob, path + '*')
889889
store = DBMStore(path, flag='n')
890890
return store, None
891891

@@ -911,7 +911,7 @@ class TestGroupWithLMDBStore(TestGroup):
911911
@staticmethod
912912
def create_store():
913913
path = tempfile.mktemp(suffix='.lmdb')
914-
atexit_rmtree(path)
914+
atexit.register(atexit_rmtree, path)
915915
try:
916916
store = LMDBStore(path)
917917
except ImportError: # pragma: no cover

zarr/tests/test_storage.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -748,8 +748,8 @@ def test_pop(self):
748748
class TestDBMStore(StoreTests, unittest.TestCase):
749749

750750
def create_store(self):
751-
path = tempfile.mktemp(suffix='.dbm')
752-
atexit.register(os.remove, path)
751+
path = tempfile.mktemp(suffix='.anydbm')
752+
atexit.register(atexit_rmglob, path + '*')
753753
store = DBMStore(path, flag='n')
754754
return store
755755

@@ -764,7 +764,7 @@ class TestDBMStoreDumb(TestDBMStore):
764764

765765
def create_store(self):
766766
path = tempfile.mktemp(suffix='.dumbdbm')
767-
atexit_rmglob(path + '*')
767+
atexit.register(atexit_rmglob, path + '*')
768768
if PY2: # pragma: py3 no cover
769769
import dumbdbm
770770
else: # pragma: py2 no cover
@@ -799,7 +799,7 @@ class TestDBMStoreNDBM(TestDBMStore):
799799

800800
def create_store(self):
801801
path = tempfile.mktemp(suffix='.ndbm')
802-
atexit_rmglob(path + '*')
802+
atexit.register(atexit_rmglob, path + '*')
803803
store = DBMStore(path, flag='n', open=ndbm.open)
804804
return store
805805

@@ -826,7 +826,7 @@ class TestLMDBStore(StoreTests, unittest.TestCase):
826826

827827
def create_store(self):
828828
path = tempfile.mktemp(suffix='.lmdb')
829-
atexit_rmtree(path)
829+
atexit.register(atexit_rmtree, path)
830830
if PY2: # pragma: py3 no cover
831831
# don't use buffers, otherwise would have to rewrite tests as bytes and
832832
# buffer don't compare equal in PY2

0 commit comments

Comments
 (0)