@@ -1142,7 +1142,12 @@ def get_dask_names(ds):
1142
1142
for k , v in new_dask_names .items ():
1143
1143
assert v == orig_dask_names [k ]
1144
1144
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
+ ):
1146
1151
data .chunk ({"foo" : 10 })
1147
1152
1148
1153
@requires_dask
@@ -3650,7 +3655,12 @@ def test_unstack(self) -> None:
3650
3655
3651
3656
def test_unstack_errors (self ) -> None :
3652
3657
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
+ ):
3654
3664
ds .unstack ("foo" )
3655
3665
with pytest .raises (ValueError , match = r".*do not have exactly one multi-index" ):
3656
3666
ds .unstack ("x" )
@@ -5496,7 +5506,12 @@ def test_rank(self) -> None:
5496
5506
assert list (z .coords ) == list (ds .coords )
5497
5507
assert list (x .coords ) == list (y .coords )
5498
5508
# 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
+ ):
5500
5515
x .rank ("invalid_dim" )
5501
5516
5502
5517
def test_rank_use_bottleneck (self ) -> None :
@@ -7029,7 +7044,12 @@ def test_drop_duplicates_1d(self, keep) -> None:
7029
7044
result = ds .drop_duplicates ("time" , keep = keep )
7030
7045
assert_equal (expected , result )
7031
7046
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
+ ):
7033
7053
ds .drop_duplicates ("space" , keep = keep )
7034
7054
7035
7055
0 commit comments