From 155ceb02ae70dbd32f2e02fa9f298662590ceb43 Mon Sep 17 00:00:00 2001 From: Carl Andersson Date: Fri, 10 Nov 2023 14:22:30 +0100 Subject: [PATCH] Adds test for closing a zarr store created internally --- xarray/tests/test_backends.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/xarray/tests/test_backends.py b/xarray/tests/test_backends.py index 73352c3f7e1..09163c63b8a 100644 --- a/xarray/tests/test_backends.py +++ b/xarray/tests/test_backends.py @@ -5431,3 +5431,13 @@ def test_raise_writing_to_nczarr(self, mode) -> None: def test_pickle_open_mfdataset_dataset(): ds = open_example_mfdataset(["bears.nc"]) assert_identical(ds, pickle.loads(pickle.dumps(ds))) + + +@requires_zarr +def test_zarr_closing_internal_zip_store(): + store_name = "tmp.zarr.zip" + original_da = DataArray(np.arange(12).reshape((3, 4))) + original_da.to_zarr(store_name, mode="w") + + with open_dataarray(store_name, engine="zarr") as loaded_da: + assert_identical(original_da, loaded_da)