@@ -160,11 +160,12 @@ def test_getitem_mask(self, data):
160
160
161
161
def test_getitem_mask_raises (self , data ):
162
162
mask = np .array ([True , False ])
163
- with pytest .raises (IndexError ):
163
+ msg = f"Boolean index has wrong length: 2 instead of { len (data )} "
164
+ with pytest .raises (IndexError , match = msg ):
164
165
data [mask ]
165
166
166
167
mask = pd .array (mask , dtype = "boolean" )
167
- with pytest .raises (IndexError ):
168
+ with pytest .raises (IndexError , match = msg ):
168
169
data [mask ]
169
170
170
171
def test_getitem_boolean_array_mask (self , data ):
@@ -305,7 +306,9 @@ def test_take_empty(self, data, na_value, na_cmp):
305
306
result = empty .take ([- 1 ], allow_fill = True )
306
307
assert na_cmp (result [0 ], na_value )
307
308
308
- with pytest .raises (IndexError ):
309
+ msg = "cannot do a non-empty take from an empty axes|out of bounds"
310
+
311
+ with pytest .raises (IndexError , match = msg ):
309
312
empty .take ([- 1 ])
310
313
311
314
with pytest .raises (IndexError , match = "cannot do a non-empty take" ):
@@ -330,13 +333,14 @@ def test_take_non_na_fill_value(self, data_missing):
330
333
self .assert_extension_array_equal (result , expected )
331
334
332
335
def test_take_pandas_style_negative_raises (self , data , na_value ):
333
- with pytest .raises (ValueError ):
336
+ with pytest .raises (ValueError , match = "" ):
334
337
data .take ([0 , - 2 ], fill_value = na_value , allow_fill = True )
335
338
336
339
@pytest .mark .parametrize ("allow_fill" , [True , False ])
337
340
def test_take_out_of_bounds_raises (self , data , allow_fill ):
338
341
arr = data [:3 ]
339
- with pytest .raises (IndexError ):
342
+
343
+ with pytest .raises (IndexError , match = "out of bounds|out-of-bounds" ):
340
344
arr .take (np .asarray ([0 , 3 ]), allow_fill = allow_fill )
341
345
342
346
def test_take_series (self , data ):
0 commit comments