Skip to content

Commit 4f22144

Browse files
committed
Update tests for dataset
1 parent 319dc7f commit 4f22144

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

xarray/tests/test_dataset.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,12 @@ def get_dask_names(ds):
11421142
for k, v in new_dask_names.items():
11431143
assert v == orig_dask_names[k]
11441144

1145-
with pytest.raises(ValueError, match=r"some chunks"):
1145+
with pytest.raises(
1146+
ValueError,
1147+
match=re.escape(
1148+
"chunks keys ('foo',) not found in dataset dimensions ('dim2', 'dim3', 'time', 'dim1')"
1149+
),
1150+
):
11461151
data.chunk({"foo": 10})
11471152

11481153
@requires_dask
@@ -3650,7 +3655,12 @@ def test_unstack(self) -> None:
36503655

36513656
def test_unstack_errors(self) -> None:
36523657
ds = Dataset({"x": [1, 2, 3]})
3653-
with pytest.raises(ValueError, match=r"does not contain the dimensions"):
3658+
with pytest.raises(
3659+
ValueError,
3660+
match=re.escape(
3661+
"Dimensions ('foo',) not found in dataset dimensions ('x',)"
3662+
),
3663+
):
36543664
ds.unstack("foo")
36553665
with pytest.raises(ValueError, match=r".*do not have exactly one multi-index"):
36563666
ds.unstack("x")
@@ -5496,7 +5506,12 @@ def test_rank(self) -> None:
54965506
assert list(z.coords) == list(ds.coords)
54975507
assert list(x.coords) == list(y.coords)
54985508
# invalid dim
5499-
with pytest.raises(ValueError, match=r"does not contain"):
5509+
with pytest.raises(
5510+
ValueError,
5511+
match=re.escape(
5512+
"Dimension 'invalid_dim' not found in dataset dimensions ('dim3', 'dim1')"
5513+
),
5514+
):
55005515
x.rank("invalid_dim")
55015516

55025517
def test_rank_use_bottleneck(self) -> None:
@@ -7029,7 +7044,12 @@ def test_drop_duplicates_1d(self, keep) -> None:
70297044
result = ds.drop_duplicates("time", keep=keep)
70307045
assert_equal(expected, result)
70317046

7032-
with pytest.raises(ValueError, match="['space'] not found"):
7047+
with pytest.raises(
7048+
ValueError,
7049+
match=re.escape(
7050+
"Dimensions ('space',) not found in dataset dimensions ('time',)"
7051+
),
7052+
):
70337053
ds.drop_duplicates("space", keep=keep)
70347054

70357055

0 commit comments

Comments
 (0)