Skip to content

Commit efa0017

Browse files
committed
fix tests: update the error message
1 parent 715fa9c commit efa0017

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

pandas/tests/frame/indexing/test_indexing.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,9 +564,10 @@ def test_getitem_setitem_integer_slice_keyerrors(self):
564564

565565
# non-monotonic, raise KeyError
566566
df2 = df.iloc[list(range(5)) + list(range(5, 10))[::-1]]
567-
with pytest.raises(KeyError, match=r"^3$"):
567+
msg = "non-monotonic index with a non-specific label: 3"
568+
with pytest.raises(KeyError, match=msg):
568569
df2.loc[3:11]
569-
with pytest.raises(KeyError, match=r"^3$"):
570+
with pytest.raises(KeyError, match=msg):
570571
df2.loc[3:11] = 0
571572

572573
def test_fancy_getitem_slice_mixed(self, float_frame, float_string_frame):

pandas/tests/indexes/numeric/test_indexing.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,10 +600,11 @@ def test_slice_locs_na(self):
600600

601601
def test_slice_locs_na_raises(self):
602602
index = Index([np.nan, 1, 2])
603-
with pytest.raises(KeyError, match="1.5"):
603+
msg = "non-monotonic index with a non-specific label: 1.5"
604+
with pytest.raises(KeyError, match=msg):
604605
index.slice_locs(start=1.5)
605606

606-
with pytest.raises(KeyError, match="1.5"):
607+
with pytest.raises(KeyError, match=msg):
607608
index.slice_locs(end=1.5)
608609

609610

pandas/tests/indexing/test_loc.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3162,9 +3162,10 @@ def test_loc_getitem_setitem_integer_slice_keyerrors(self):
31623162

31633163
# non-monotonic, raise KeyError
31643164
s2 = ser.iloc[list(range(5)) + list(range(9, 4, -1))]
3165-
with pytest.raises(KeyError, match=r"^3$"):
3165+
msg = "non-monotonic index with a non-specific label: 3"
3166+
with pytest.raises(KeyError, match=msg):
31663167
s2.loc[3:11]
3167-
with pytest.raises(KeyError, match=r"^3$"):
3168+
with pytest.raises(KeyError, match=msg):
31683169
s2.loc[3:11] = 0
31693170

31703171
def test_loc_getitem_iterator(self, string_series):

0 commit comments

Comments
 (0)