Skip to content

Commit 51554f2

Browse files
jhammanIllviljan
andauthored
test: Fix test_write_read_select_write for Zarr V3 (#7825)
Previously, the first context manager in this test was closed before accessing the data. This resulted in key errors when trying to access the opened dataset. Co-authored-by: Illviljan <[email protected]>
1 parent a9f9d1e commit 51554f2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

xarray/tests/test_backends.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2584,10 +2584,10 @@ def test_write_read_select_write(self) -> None:
25842584
ds.to_zarr(initial_store, mode="w", **self.version_kwargs)
25852585
ds1 = xr.open_zarr(initial_store, **self.version_kwargs)
25862586

2587-
# Combination of where+squeeze triggers error on write.
2588-
ds_sel = ds1.where(ds1.coords["dim3"] == "a", drop=True).squeeze("dim3")
2589-
with self.create_zarr_target() as final_store:
2590-
ds_sel.to_zarr(final_store, mode="w", **self.version_kwargs)
2587+
# Combination of where+squeeze triggers error on write.
2588+
ds_sel = ds1.where(ds1.coords["dim3"] == "a", drop=True).squeeze("dim3")
2589+
with self.create_zarr_target() as final_store:
2590+
ds_sel.to_zarr(final_store, mode="w", **self.version_kwargs)
25912591

25922592
@pytest.mark.parametrize("obj", [Dataset(), DataArray(name="foo")])
25932593
def test_attributes(self, obj) -> None:

0 commit comments

Comments
 (0)