@@ -827,6 +827,34 @@ def test_normalize_keys(self):
827
827
assert 'FOO' in store
828
828
assert 'foo' in store
829
829
830
+ def test_listing_keys_slash (self ):
831
+
832
+ def mock_walker_slash (_path ):
833
+ yield from [
834
+ # trailing slash in first key
835
+ ('root_with_slash/' , ['d1' , 'g1' ], ['.zgroup' ]),
836
+ ('root_with_slash/d1' , [], ['.zarray' ]),
837
+ ('root_with_slash/g1' , [], ['.zgroup' ])
838
+ ]
839
+
840
+ res = set (DirectoryStore ._keys_fast ('root_with_slash/' , walker = mock_walker_slash ))
841
+ assert res == {'.zgroup' , 'g1/.zgroup' , 'd1/.zarray' }
842
+
843
+ def test_listing_keys_no_slash (self ):
844
+
845
+ def mock_walker_no_slash (_path ):
846
+ yield from [
847
+ # no trainling slash in first key
848
+ ('root_with_no_slash' , ['d1' , 'g1' ], ['.zgroup' ]),
849
+ ('root_with_no_slash/d1' , [], ['.zarray' ]),
850
+ ('root_with_no_slash/g1' , [], ['.zgroup' ])
851
+ ]
852
+
853
+ res = set (
854
+ DirectoryStore ._keys_fast ('root_with_no_slash' , mock_walker_no_slash )
855
+ )
856
+ assert res == {'.zgroup' , 'g1/.zgroup' , 'd1/.zarray' }
857
+
830
858
831
859
@pytest .mark .skipif (have_fsspec is False , reason = "needs fsspec" )
832
860
class TestFSStore (StoreTests , unittest .TestCase ):
0 commit comments