diff --git a/pandas/tests/indexing/multiindex/test_partial.py b/pandas/tests/indexing/multiindex/test_partial.py index 9c356b81b85db2..c203d986efd23f 100644 --- a/pandas/tests/indexing/multiindex/test_partial.py +++ b/pandas/tests/indexing/multiindex/test_partial.py @@ -178,9 +178,9 @@ def test_partial_loc_missing(self, multiindex_year_month_day_dataframe_random_da # assert (self.ymd.loc[2000]['A'] == 0).all() # Pretty sure the second (and maybe even the first) is already wrong. - with pytest.raises(Exception): + with pytest.raises(KeyError, match="6"): ymd.loc[(2000, 6)] - with pytest.raises(Exception): + with pytest.raises(KeyError, match="(2000, 6)"): ymd.loc[(2000, 6), 0] # --------------------------------------------------------------------- diff --git a/pandas/tests/indexing/test_coercion.py b/pandas/tests/indexing/test_coercion.py index 15f58006426f49..41f967ce327968 100644 --- a/pandas/tests/indexing/test_coercion.py +++ b/pandas/tests/indexing/test_coercion.py @@ -331,7 +331,8 @@ def test_setitem_index_float64(self, val, exp_dtype, request): if exp_dtype is IndexError: # float + int -> int temp = obj.copy() - with pytest.raises(exp_dtype): + msg = "index 5 is out of bounds for axis 0 with size 4" + with pytest.raises(exp_dtype, match=msg): temp[5] = 5 mark = pytest.mark.xfail(reason="TODO_GH12747 The result must be float") request.node.add_marker(mark)