@@ -297,7 +297,8 @@ def test_delete(self):
297
297
assert (newb .values [1 ] == 1 ).all ()
298
298
299
299
newb = self .fblock .copy ()
300
- with pytest .raises (Exception ):
300
+
301
+ with pytest .raises (IndexError , match = None ):
301
302
newb .delete (3 )
302
303
303
304
@@ -321,7 +322,12 @@ def test_can_hold_element(self):
321
322
322
323
val = date (2010 , 10 , 10 )
323
324
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 ):
325
331
arr [0 ] = val
326
332
327
333
@@ -350,7 +356,10 @@ def test_duplicate_ref_loc_failure(self):
350
356
blocks [1 ].mgr_locs = np .array ([0 ])
351
357
352
358
# 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 ):
354
363
BlockManager (blocks , axes )
355
364
356
365
blocks [0 ].mgr_locs = np .array ([0 ])
@@ -808,7 +817,11 @@ def test_validate_bool_args(self):
808
817
bm1 = create_mgr ("a,b,c: i8-1; d,e,f: i8-2" )
809
818
810
819
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 ):
812
825
bm1 .replace_list ([1 ], [2 ], inplace = value )
813
826
814
827
@@ -1027,9 +1040,11 @@ def test_slice_len(self):
1027
1040
assert len (BlockPlacement (slice (1 , 0 , - 1 ))) == 1
1028
1041
1029
1042
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 ):
1031
1046
BlockPlacement (slice (1 , 1 , 0 ))
1032
- with pytest .raises (ValueError ):
1047
+ with pytest .raises (ValueError , match = msg ):
1033
1048
BlockPlacement (slice (1 , 2 , 0 ))
1034
1049
1035
1050
def test_unbounded_slice_raises (self ):
@@ -1132,9 +1147,11 @@ def assert_add_equals(val, inc, result):
1132
1147
assert_add_equals (slice (1 , 4 ), - 1 , [0 , 1 , 2 ])
1133
1148
assert_add_equals ([1 , 2 , 4 ], - 1 , [0 , 1 , 3 ])
1134
1149
1135
- with pytest .raises (ValueError ):
1150
+ msg = "iadd causes length change"
1151
+
1152
+ with pytest .raises (ValueError , match = msg ):
1136
1153
BlockPlacement (slice (1 , 4 )).add (- 10 )
1137
- with pytest .raises (ValueError ):
1154
+ with pytest .raises (ValueError , match = msg ):
1138
1155
BlockPlacement ([1 , 2 , 4 ]).add (- 10 )
1139
1156
1140
1157
0 commit comments