Skip to content

Commit 03d8d56

Browse files
authored
Remove unexpected warnings in tests (#4728)
* fix test on chunking (warnings for not close files) * add filterwarnings in test_chunking_consistency * add filterwarnings in test_remove_duplicates
1 parent ed0dadc commit 03d8d56

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

xarray/backends/plugins.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def remove_duplicates(backend_entrypoints):
3333
selected_module_name = matches[0].module_name
3434
all_module_names = [e.module_name for e in matches]
3535
warnings.warn(
36-
f"\nFound {matches_len} entrypoints for the engine name {name}:"
36+
f"Found {matches_len} entrypoints for the engine name {name}:"
3737
f"\n {all_module_names}.\n It will be used: {selected_module_name}.",
3838
RuntimeWarning,
3939
)

xarray/tests/test_backends.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -4838,15 +4838,18 @@ def test_open_dataset_chunking_zarr(chunks, tmp_path):
48384838

48394839
with dask.config.set({"array.chunk-size": "1MiB"}):
48404840
expected = ds.chunk(chunks)
4841-
actual = xr.open_dataset(tmp_path / "test.zarr", engine="zarr", chunks=chunks)
4842-
xr.testing.assert_chunks_equal(actual, expected)
4841+
with open_dataset(
4842+
tmp_path / "test.zarr", engine="zarr", chunks=chunks
4843+
) as actual:
4844+
xr.testing.assert_chunks_equal(actual, expected)
48434845

48444846

48454847
@requires_zarr
48464848
@requires_dask
48474849
@pytest.mark.parametrize(
48484850
"chunks", ["auto", -1, {}, {"x": "auto"}, {"x": -1}, {"x": "auto", "y": -1}]
48494851
)
4852+
@pytest.mark.filterwarnings("ignore:Specified Dask chunks")
48504853
def test_chunking_consintency(chunks, tmp_path):
48514854
encoded_chunks = {}
48524855
dask_arr = da.from_array(
@@ -4866,8 +4869,10 @@ def test_chunking_consintency(chunks, tmp_path):
48664869

48674870
with dask.config.set({"array.chunk-size": "1MiB"}):
48684871
expected = ds.chunk(chunks)
4869-
actual = xr.open_dataset(tmp_path / "test.zarr", engine="zarr", chunks=chunks)
4870-
xr.testing.assert_chunks_equal(actual, expected)
4872+
with xr.open_dataset(
4873+
tmp_path / "test.zarr", engine="zarr", chunks=chunks
4874+
) as actual:
4875+
xr.testing.assert_chunks_equal(actual, expected)
48714876

4872-
actual = xr.open_dataset(tmp_path / "test.nc", chunks=chunks)
4873-
xr.testing.assert_chunks_equal(actual, expected)
4877+
with xr.open_dataset(tmp_path / "test.nc", chunks=chunks) as actual:
4878+
xr.testing.assert_chunks_equal(actual, expected)

xarray/tests/test_plugins.py

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def dummy_duplicated_entrypoints():
3030
return eps
3131

3232

33+
@pytest.mark.filterwarnings("ignore:Found")
3334
def test_remove_duplicates(dummy_duplicated_entrypoints):
3435
entrypoints = plugins.remove_duplicates(dummy_duplicated_entrypoints)
3536
assert len(entrypoints) == 2

0 commit comments

Comments
 (0)