@@ -7149,6 +7149,31 @@ def test_h5netcdf_entrypoint(tmp_path: Path) -> None:
7149
7149
assert not entrypoint .guess_can_open ("not-found-and-no-extension" )
7150
7150
7151
7151
7152
+ @requires_zarr
7153
+ def test_zarr_entrypoint (tmp_path : Path ) -> None :
7154
+ from xarray .backends .zarr import ZarrBackendEntrypoint
7155
+
7156
+ entrypoint = ZarrBackendEntrypoint ()
7157
+ ds = create_test_data ()
7158
+
7159
+ path = tmp_path / "foo.zarr"
7160
+ ds .to_zarr (path )
7161
+ _check_guess_can_open_and_open (entrypoint , path , engine = "zarr" , expected = ds )
7162
+ _check_guess_can_open_and_open (entrypoint , str (path ), engine = "zarr" , expected = ds )
7163
+
7164
+ # add a trailing slash to the path and check again
7165
+ _check_guess_can_open_and_open (
7166
+ entrypoint , str (path ) + "/" , engine = "zarr" , expected = ds
7167
+ )
7168
+
7169
+ # Test the new functionality: .zarr with trailing slash
7170
+ assert entrypoint .guess_can_open ("something-local.zarr" )
7171
+ assert entrypoint .guess_can_open ("something-local.zarr/" ) # With trailing slash
7172
+ assert not entrypoint .guess_can_open ("something-local.nc" )
7173
+ assert not entrypoint .guess_can_open ("not-found-and-no-extension" )
7174
+ assert not entrypoint .guess_can_open ("something.zarr.txt" )
7175
+
7176
+
7152
7177
@requires_netCDF4
7153
7178
@pytest .mark .parametrize ("str_type" , (str , np .str_ ))
7154
7179
def test_write_file_from_np_str (str_type : type [str | np .str_ ], tmpdir : str ) -> None :
0 commit comments