@@ -297,7 +297,8 @@ def test_delete(self):
297297 assert (newb .values [1 ] == 1 ).all ()
298298
299299 newb = self .fblock .copy ()
300- with pytest .raises (Exception ):
300+
301+ with pytest .raises (IndexError , match = None ):
301302 newb .delete (3 )
302303
303304
@@ -321,7 +322,12 @@ def test_can_hold_element(self):
321322
322323 val = date (2010 , 10 , 10 )
323324 assert not block ._can_hold_element (val )
324- with pytest .raises (TypeError ):
325+
326+ msg = (
327+ "'value' should be a 'Timestamp', 'NaT', "
328+ "or array of those. Got 'date' instead."
329+ )
330+ with pytest .raises (TypeError , match = msg ):
325331 arr [0 ] = val
326332
327333
@@ -350,7 +356,10 @@ def test_duplicate_ref_loc_failure(self):
350356 blocks [1 ].mgr_locs = np .array ([0 ])
351357
352358 # test trying to create block manager with overlapping ref locs
353- with pytest .raises (AssertionError ):
359+
360+ msg = "Gaps in blk ref_locs"
361+
362+ with pytest .raises (AssertionError , match = msg ):
354363 BlockManager (blocks , axes )
355364
356365 blocks [0 ].mgr_locs = np .array ([0 ])
@@ -808,7 +817,11 @@ def test_validate_bool_args(self):
808817 bm1 = create_mgr ("a,b,c: i8-1; d,e,f: i8-2" )
809818
810819 for value in invalid_values :
811- with pytest .raises (ValueError ):
820+ msg = (
821+ 'For argument "inplace" expected type bool, '
822+ f"received type { type (value ).__name__ } ."
823+ )
824+ with pytest .raises (ValueError , match = msg ):
812825 bm1 .replace_list ([1 ], [2 ], inplace = value )
813826
814827
@@ -1027,9 +1040,11 @@ def test_slice_len(self):
10271040 assert len (BlockPlacement (slice (1 , 0 , - 1 ))) == 1
10281041
10291042 def test_zero_step_raises (self ):
1030- with pytest .raises (ValueError ):
1043+ msg = "slice step cannot be zero"
1044+
1045+ with pytest .raises (ValueError , match = msg ):
10311046 BlockPlacement (slice (1 , 1 , 0 ))
1032- with pytest .raises (ValueError ):
1047+ with pytest .raises (ValueError , match = msg ):
10331048 BlockPlacement (slice (1 , 2 , 0 ))
10341049
10351050 def test_unbounded_slice_raises (self ):
@@ -1132,9 +1147,11 @@ def assert_add_equals(val, inc, result):
11321147 assert_add_equals (slice (1 , 4 ), - 1 , [0 , 1 , 2 ])
11331148 assert_add_equals ([1 , 2 , 4 ], - 1 , [0 , 1 , 3 ])
11341149
1135- with pytest .raises (ValueError ):
1150+ msg = "iadd causes length change"
1151+
1152+ with pytest .raises (ValueError , match = msg ):
11361153 BlockPlacement (slice (1 , 4 )).add (- 10 )
1137- with pytest .raises (ValueError ):
1154+ with pytest .raises (ValueError , match = msg ):
11381155 BlockPlacement ([1 , 2 , 4 ]).add (- 10 )
11391156
11401157
0 commit comments