Skip to content

Commit 192fc8b

Browse files
committed
update tests
1 parent 5efbe30 commit 192fc8b

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

xarray/tests/test_backends.py

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3401,8 +3401,8 @@ def test_append(self) -> None:
34013401
if has_zarr_v3:
34023402
expected = {
34033403
"set": 4,
3404-
"get": 16, # TODO: fixme upstream (should be 8)
3405-
"list_dir": 3, # TODO: fixme upstream (should be 2)
3404+
"get": 9, # TODO: fixme upstream (should be 8)
3405+
"list_dir": 2, # TODO: fixme upstream (should be 2)
34063406
"list_prefix": 0,
34073407
}
34083408
else:
@@ -3424,8 +3424,8 @@ def test_append(self) -> None:
34243424
if has_zarr_v3:
34253425
expected = {
34263426
"set": 4,
3427-
"get": 16, # TODO: fixme upstream (should be 8)
3428-
"list_dir": 3, # TODO: fixme upstream (should be 2)
3427+
"get": 9, # TODO: fixme upstream (should be 8)
3428+
"list_dir": 2, # TODO: fixme upstream (should be 2)
34293429
"list_prefix": 0,
34303430
}
34313431
else:
@@ -3479,7 +3479,7 @@ def test_region_write(self) -> None:
34793479
expected = {
34803480
"set": 1,
34813481
"get": 3,
3482-
"list_dir": 2,
3482+
"list_dir": 0,
34833483
"list_prefix": 0,
34843484
}
34853485
else:
@@ -3502,8 +3502,8 @@ def test_region_write(self) -> None:
35023502
if has_zarr_v3:
35033503
expected = {
35043504
"set": 1,
3505-
"get": 5,
3506-
"list_dir": 2,
3505+
"get": 4,
3506+
"list_dir": 0,
35073507
"list_prefix": 0,
35083508
}
35093509
else:
@@ -3525,7 +3525,7 @@ def test_region_write(self) -> None:
35253525
expected = {
35263526
"set": 0,
35273527
"get": 5,
3528-
"list_dir": 1,
3528+
"list_dir": 0,
35293529
"list_prefix": 0,
35303530
}
35313531
else:
@@ -3567,13 +3567,26 @@ def create_zarr_target(self):
35673567
yield tmp
35683568

35693569
@contextlib.contextmanager
3570-
def create_store(self, cache_members: bool = False):
3570+
def create_store(self, **kwargs):
35713571
with self.create_zarr_target() as store_target:
3572-
group = backends.ZarrStore.open_group(
3573-
store_target, mode="a", cache_members=cache_members
3574-
)
3572+
group = backends.ZarrStore.open_group(store_target, mode="a", **kwargs)
35753573
yield group
35763574

3575+
def test_write_store(self) -> None:
3576+
# This test is overriden from the base implementation because we need to ensure
3577+
# that the members cache is off, as the `ZarrStore` instance is re-used in the
3578+
# test function. Refactoring the base version of this test to
3579+
# if this test is refactored to no longer re-use the store object, then
3580+
# this implementation can be removed.
3581+
3582+
expected = create_test_data()
3583+
with self.create_store(cache_members=False) as store:
3584+
expected.dump_to_store(store)
3585+
# we need to cf decode the store because it has time and
3586+
# non-dimension coordinates
3587+
with xr.decode_cf(store) as actual:
3588+
assert_allclose(expected, actual)
3589+
35773590

35783591
@requires_zarr
35793592
class TestZarrWriteEmpty(TestZarrDirectoryStore):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy