Skip to content

Commit b6e8935

Browse files
committed
test + userwarning
1 parent d78d177 commit b6e8935

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/zarr/core/group.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import itertools
55
import json
66
import logging
7+
import warnings
78
from collections import defaultdict
89
from dataclasses import asdict, dataclass, field, fields, replace
910
from typing import TYPE_CHECKING, Literal, TypeVar, assert_never, cast, overload
@@ -1170,9 +1171,10 @@ async def _members(
11701171
# keyerror is raised when `key` names an object (in the object storage sense),
11711172
# as opposed to a prefix, in the store under the prefix associated with this group
11721173
# in which case `key` cannot be the name of a sub-array or sub-group.
1173-
logger.warning(
1174-
"Object at %s is not recognized as a component of a Zarr hierarchy.",
1175-
key,
1174+
warnings.warn(
1175+
f"Object at {key} is not recognized as a component of a Zarr hierarchy.",
1176+
UserWarning,
1177+
stacklevel=1,
11761178
)
11771179

11781180
def _members_consolidated(

tests/v3/test_group.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import pickle
4+
import warnings
45
from typing import TYPE_CHECKING, Any, Literal, cast
56

67
import numpy as np
@@ -1091,8 +1092,8 @@ async def test_require_array(store: Store, zarr_format: ZarrFormat) -> None:
10911092

10921093

10931094
@pytest.mark.parametrize("consolidate", [True, False])
1094-
def test_members_name(store: Store, consolidate: bool):
1095-
group = Group.from_store(store=store)
1095+
async def test_members_name(store: Store, consolidate: bool, zarr_format: ZarrFormat):
1096+
group = Group.from_store(store=store, zarr_format=zarr_format)
10961097
a = group.create_group(name="a")
10971098
a.create_array("array", shape=(1,))
10981099
b = a.create_group(name="b")
@@ -1108,6 +1109,12 @@ def test_members_name(store: Store, consolidate: bool):
11081109
expected = ["/a", "/a/array", "/a/b", "/a/b/array"]
11091110
assert paths == expected
11101111

1112+
# regression test for https://github.com/zarr-developers/zarr-python/pull/2356
1113+
g = zarr.open_group(store, use_consolidated=False)
1114+
with warnings.catch_warnings():
1115+
warnings.simplefilter("error")
1116+
assert list(g)
1117+
11111118

11121119
async def test_open_mutable_mapping():
11131120
group = await zarr.api.asynchronous.open_group(store={}, mode="w")

0 commit comments

Comments
 (0)