-
-
Notifications
You must be signed in to change notification settings - Fork 351
add enter and exit methods to groups. #2691
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -428,6 +428,28 @@ def test_group_len(store: Store, zarr_format: ZarrFormat) -> None: | |
assert len(group) == 0 | ||
|
||
|
||
def test_group_with_context_manager(store: Store, zarr_format: ZarrFormat, overwrite: bool) -> None: | ||
spath = StorePath(store) | ||
|
||
# attempt to open a group that does not exist. | ||
with pytest.raises(FileNotFoundError): | ||
with Group.open(store) as store: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also, instead of using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated in 3aee7b0 |
||
pass | ||
|
||
attrs = {"path": "foo"} | ||
|
||
with Group.from_store( | ||
store, attributes=attrs, zarr_format=zarr_format, overwrite=overwrite | ||
) as group: | ||
assert store._is_open | ||
assert group.attrs == attrs | ||
assert group.metadata.zarr_format == zarr_format | ||
assert group.store_path == spath | ||
|
||
# Check if store was closed after exit. | ||
assert not store._is_open | ||
jhamman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
def test_group_setitem(store: Store, zarr_format: ZarrFormat) -> None: | ||
""" | ||
Test the `Group.__setitem__` method. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated in 3aee7b0