Skip to content

Commit 7cf6f80

Browse files
committed
Tests for pathlib use
1 parent 2241a26 commit 7cf6f80

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

zarr/tests/conftest.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from pathlib import Path
2+
3+
import pytest
4+
5+
6+
@pytest.fixture(params=[str, Path])
7+
def path_type(request):
8+
return request.param

zarr/tests/test_convenience.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@
2727
atexit_rmtree, getsize)
2828

2929

30-
def test_open_array():
30+
def test_open_array(path_type):
3131

3232
store = tempfile.mkdtemp()
3333
atexit.register(atexit_rmtree, store)
34+
store = path_type(store)
3435

3536
# open array, create if doesn't exist
3637
z = open(store, mode='a', shape=100)
@@ -53,10 +54,11 @@ def test_open_array():
5354
open('doesnotexist', mode='r')
5455

5556

56-
def test_open_group():
57+
def test_open_group(path_type):
5758

5859
store = tempfile.mkdtemp()
5960
atexit.register(atexit_rmtree, store)
61+
store = path_type(store)
6062

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

zarr/tests/test_storage.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import atexit
33
import json
44
import os
5+
from pathlib import Path
56
import sys
67
import pickle
78
import shutil
@@ -836,6 +837,11 @@ def test_filesystem_path(self):
836837
with pytest.raises(ValueError):
837838
DirectoryStore(f.name)
838839

840+
def test_init_pathlib(self):
841+
path = tempfile.mkdtemp()
842+
atexit.register(atexit_rmtree, path)
843+
DirectoryStore(Path(path))
844+
839845
def test_pickle_ext(self):
840846
store = self.create_store()
841847
store2 = pickle.loads(pickle.dumps(store))

0 commit comments

Comments
 (0)