11from __future__ import annotations
22
3- from typing import TYPE_CHECKING
3+ import pathlib
44
55import numpy as np
66import pytest
1212from zarr .testing .store import StoreTests
1313from zarr .testing .utils import assert_bytes_equal
1414
15- if TYPE_CHECKING :
16- import pathlib
17-
1815
1916class TestLocalStore (StoreTests [LocalStore , cpu .Buffer ]):
2017 store_cls = LocalStore
@@ -77,11 +74,20 @@ async def test_get_with_prototype_default(self, store: LocalStore) -> None:
7774 observed = await store .get (key , prototype = None )
7875 assert_bytes_equal (observed , data_buf )
7976
80- @pytest .mark .parametrize ("ndim" , [0 , 1 , 2 , 3 ])
81- async def test_move (self , tmp_path : pathlib .Path , ndim ):
77+ @pytest .mark .parametrize ("ndim" , [0 , 1 , 3 ])
78+ @pytest .mark .parametrize (
79+ "destination" , ["destination" , "foo/bar/destintion" , pathlib .Path ("foo/bar/destintion" )]
80+ )
81+ async def test_move (
82+ self , tmp_path : pathlib .Path , ndim : int , destination : pathlib .Path | str
83+ ) -> None :
8284 origin = tmp_path / "origin"
83- destination = tmp_path / "destintion"
85+ if isinstance (destination , str ):
86+ destination = str (tmp_path / destination )
87+ else :
88+ destination = tmp_path / destination
8489
90+ print (type (destination ))
8591 store = await LocalStore .open (root = origin )
8692 shape = (4 ,) * ndim
8793 chunks = (2 ,) * ndim
@@ -90,9 +96,13 @@ async def test_move(self, tmp_path: pathlib.Path, ndim):
9096 data = data .reshape (* shape )
9197 array = create_array (store , data = data , chunks = chunks or "auto" )
9298
93- await store .move (str ( destination ) )
99+ await store .move (destination )
94100
95- assert store .root == destination
96- assert destination .exists ()
101+ assert store .root == pathlib . Path ( destination )
102+ assert pathlib . Path ( destination ) .exists ()
97103 assert not origin .exists ()
98104 assert np .array_equal (array [...], data )
105+
106+ store2 = await LocalStore .open (root = origin )
107+ with pytest .raises (FileExistsError , match = f"Destination root { destination } already exists" ):
108+ await store2 .move (destination )
0 commit comments