Skip to content

Commit dd52445

Browse files
authored
TST: GH30999 Change all pytest.raises in pandas/tests/indexing to tm.external_error_raised (#38825)
1 parent 784de76 commit dd52445

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

pandas/tests/indexing/multiindex/test_partial.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,9 @@ def test_partial_loc_missing(self, multiindex_year_month_day_dataframe_random_da
178178
# assert (self.ymd.loc[2000]['A'] == 0).all()
179179

180180
# Pretty sure the second (and maybe even the first) is already wrong.
181-
with pytest.raises(Exception):
181+
with pytest.raises(KeyError, match="6"):
182182
ymd.loc[(2000, 6)]
183-
with pytest.raises(Exception):
183+
with pytest.raises(KeyError, match="(2000, 6)"):
184184
ymd.loc[(2000, 6), 0]
185185

186186
# ---------------------------------------------------------------------

pandas/tests/indexing/test_coercion.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,8 @@ def test_setitem_index_float64(self, val, exp_dtype, request):
331331
if exp_dtype is IndexError:
332332
# float + int -> int
333333
temp = obj.copy()
334-
with pytest.raises(exp_dtype):
334+
msg = "index 5 is out of bounds for axis 0 with size 4"
335+
with pytest.raises(exp_dtype, match=msg):
335336
temp[5] = 5
336337
mark = pytest.mark.xfail(reason="TODO_GH12747 The result must be float")
337338
request.node.add_marker(mark)

0 commit comments

Comments
 (0)