Skip to content

Commit ac940b1

Browse files
committed
TST: Fix/add tests with MultiIndex and no labels found
1 parent 7f42645 commit ac940b1

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

pandas/tests/indexing/test_multiindex.py

+4
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ def test_loc_getitem_series(self):
169169
result = x.loc[empty]
170170
tm.assert_series_equal(result, expected)
171171

172+
with tm.assertRaises(KeyError):
173+
# GH15452
174+
x.loc[[4, 5]]
175+
172176
def test_loc_getitem_array(self):
173177
# GH15434
174178
# passing an array as a key with a MultiIndex

pandas/tests/sparse/test_indexing.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -512,13 +512,17 @@ def test_loc(self):
512512
tm.assert_sp_series_equal(sparse.loc['B'],
513513
orig.loc['B'].to_sparse())
514514

515-
result = sparse.loc[[1, 3, 4]]
516-
exp = orig.loc[[1, 3, 4]].to_sparse()
515+
with tm.assertRaises(KeyError):
516+
# GH15452
517+
sparse.loc[['D', 'E', 'F']]
518+
519+
result = sparse.loc[['A', 'B']]
520+
exp = orig.loc[['A', 'B']].to_sparse()
517521
tm.assert_sp_series_equal(result, exp)
518522

519523
# exceeds the bounds
520-
result = sparse.loc[[1, 3, 4, 5]]
521-
exp = orig.loc[[1, 3, 4, 5]].to_sparse()
524+
result = sparse.loc[['A', 'B', 'C', 'D']]
525+
exp = orig.loc[['A', 'B', 'C', 'D']].to_sparse()
522526
tm.assert_sp_series_equal(result, exp)
523527

524528
# single element list (GH 15447)

0 commit comments

Comments
 (0)