Skip to content

Commit

Permalink
expect warnings in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TomNicholas committed Jul 1, 2024
1 parent 29d8e8a commit 0c0053b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion virtualizarr/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,5 +175,5 @@ def test_open_scalar_variable(tmpdir):
ds = xr.Dataset(data_vars={"a": 0})
ds.to_netcdf(f"{tmpdir}/scalar.nc")

vds = open_virtual_dataset(f"{tmpdir}/scalar.nc")
vds = open_virtual_dataset(f"{tmpdir}/scalar.nc", indexes={})
assert vds["a"].shape == ()
13 changes: 9 additions & 4 deletions virtualizarr/tests/test_xarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ def test_no_indexes(self, netcdf4_file):
assert vds.indexes == {}

def test_create_default_indexes(self, netcdf4_file):
vds = open_virtual_dataset(netcdf4_file, indexes=None)
with pytest.warns(UserWarning, match="will create in-memory pandas indexes"):
vds = open_virtual_dataset(netcdf4_file, indexes=None)
ds = xr.open_dataset(netcdf4_file, decode_times=False)

# TODO use xr.testing.assert_identical(vds.indexes, ds.indexes) instead once class supported by assertion comparison, see https://github.com/pydata/xarray/issues/5812
Expand All @@ -278,8 +279,10 @@ class TestCombineUsingIndexes:
def test_combine_by_coords(self, netcdf4_files):
filepath1, filepath2 = netcdf4_files

vds1 = open_virtual_dataset(filepath1)
vds2 = open_virtual_dataset(filepath2)
with pytest.warns(UserWarning, match="will create in-memory pandas indexes"):
vds1 = open_virtual_dataset(filepath1)
with pytest.warns(UserWarning, match="will create in-memory pandas indexes"):
vds2 = open_virtual_dataset(filepath2)

combined_vds = xr.combine_by_coords(
[vds2, vds1],
Expand Down Expand Up @@ -363,7 +366,9 @@ def test_read_from_url(self, filetype, url):
class TestLoadVirtualDataset:
def test_loadable_variables(self, netcdf4_file):
vars_to_load = ["air", "time"]
vds = open_virtual_dataset(netcdf4_file, loadable_variables=vars_to_load)
vds = open_virtual_dataset(
netcdf4_file, loadable_variables=vars_to_load, indexes={}
)

for name in vds.variables:
if name in vars_to_load:
Expand Down

0 comments on commit 0c0053b

Please sign in to comment.