@@ -160,11 +160,12 @@ def test_getitem_mask(self, data):
160160
161161 def test_getitem_mask_raises (self , data ):
162162 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 ):
164165 data [mask ]
165166
166167 mask = pd .array (mask , dtype = "boolean" )
167- with pytest .raises (IndexError ):
168+ with pytest .raises (IndexError , match = msg ):
168169 data [mask ]
169170
170171 def test_getitem_boolean_array_mask (self , data ):
@@ -305,7 +306,9 @@ def test_take_empty(self, data, na_value, na_cmp):
305306 result = empty .take ([- 1 ], allow_fill = True )
306307 assert na_cmp (result [0 ], na_value )
307308
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 ):
309312 empty .take ([- 1 ])
310313
311314 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):
330333 self .assert_extension_array_equal (result , expected )
331334
332335 def test_take_pandas_style_negative_raises (self , data , na_value ):
333- with pytest .raises (ValueError ):
336+ with pytest .raises (ValueError , match = "" ):
334337 data .take ([0 , - 2 ], fill_value = na_value , allow_fill = True )
335338
336339 @pytest .mark .parametrize ("allow_fill" , [True , False ])
337340 def test_take_out_of_bounds_raises (self , data , allow_fill ):
338341 arr = data [:3 ]
339- with pytest .raises (IndexError ):
342+
343+ with pytest .raises (IndexError , match = "out of bounds|out-of-bounds" ):
340344 arr .take (np .asarray ([0 , 3 ]), allow_fill = allow_fill )
341345
342346 def test_take_series (self , data ):
0 commit comments