Skip to content

Commit 41a7123

Browse files
committed
fixes to get tests passing on windows
1 parent 3496462 commit 41a7123

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

zarr/storage.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ def __getitem__(self, key):
194194
def __setitem__(self, key, value):
195195
# accept any value that can be written to a file
196196

197+
# destination path for key
198+
dest_path = os.path.join(self.path, key)
199+
197200
# write to temporary file
198201
with tempfile.NamedTemporaryFile(mode='wb', delete=False,
199202
dir=self.path,
@@ -203,7 +206,9 @@ def __setitem__(self, key, value):
203206
temp_path = f.name
204207

205208
# move temporary file into place
206-
os.rename(temp_path, os.path.join(self.path, key))
209+
if os.path.exists(dest_path):
210+
os.remove(dest_path)
211+
os.rename(temp_path, dest_path)
207212

208213
def __delitem__(self, key):
209214

zarr/tests/test_core.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,13 @@ def test_nbytes_stored():
4646
eq(sum(len(v) for v in store.values()), z.nbytes_stored)
4747

4848
# custom store, doesn't support size determination
49-
with NamedTemporaryFile() as f:
50-
store = zict.Zip(f.name, mode='w')
51-
# N.B., use zlib for now as blosc extension currently not compatible
52-
# with zict,Zip
53-
init_store(store, shape=1000, chunks=100, compression='zlib',
54-
compression_opts=1)
55-
z = Array(store)
56-
eq(-1, z.nbytes_stored)
57-
z[:] = 42
58-
eq(-1, z.nbytes_stored)
49+
store = zict.Zip('test.zip', mode='w')
50+
init_store(store, shape=1000, chunks=100, compression='zlib',
51+
compression_opts=1)
52+
z = Array(store)
53+
eq(-1, z.nbytes_stored)
54+
z[:] = 42
55+
eq(-1, z.nbytes_stored)
5956

6057

6158
class TestArray(unittest.TestCase):

0 commit comments

Comments
 (0)