Skip to content

Commit 8e0ae73

Browse files
authored
TST: fix duplicate parametrization/xfail in test_setitem_integer_with_missing_raises (pandas-dev#62907)
1 parent 22e2512 commit 8e0ae73

File tree

2 files changed

+27
-20
lines changed

2 files changed

+27
-20
lines changed

pandas/tests/extension/base/setitem.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -221,28 +221,28 @@ def test_setitem_integer_array_with_repeats(self, data, idx, box_in_series):
221221
tm.assert_equal(arr, expected)
222222

223223
@pytest.mark.parametrize(
224-
"idx, box_in_series",
224+
"idx",
225225
[
226-
([0, 1, 2, pd.NA], False),
227-
pytest.param(
228-
[0, 1, 2, pd.NA], True, marks=pytest.mark.xfail(reason="GH-31948")
229-
),
230-
(pd.array([0, 1, 2, pd.NA], dtype="Int64"), False),
231-
# TODO: change False to True?
232-
(pd.array([0, 1, 2, pd.NA], dtype="Int64"), False), # noqa: PT014
226+
[0, 1, 2, pd.NA],
227+
pd.array([0, 1, 2, pd.NA], dtype="Int64"),
233228
],
234-
ids=["list-False", "list-True", "integer-array-False", "integer-array-True"],
229+
ids=["list", "integer-array"],
235230
)
231+
@pytest.mark.parametrize("box_in_series", [True, False])
236232
def test_setitem_integer_with_missing_raises(self, data, idx, box_in_series):
237233
arr = data.copy()
238234

239-
# TODO(xfail) this raises KeyError about labels not found (it tries label-based)
240-
# for list of labels with Series
235+
msg = "Cannot index with an integer indexer containing NA values"
236+
err = ValueError
237+
241238
if box_in_series:
239+
# The integer labels are not present in the (string) index, so
240+
# we get KeyErrors
242241
arr = pd.Series(data, index=[chr(100 + i) for i in range(len(data))])
242+
msg = "0"
243+
err = KeyError
243244

244-
msg = "Cannot index with an integer indexer containing NA values"
245-
with pytest.raises(ValueError, match=msg):
245+
with pytest.raises(err, match=msg):
246246
arr[idx] = arr[0]
247247

248248
@pytest.mark.parametrize("as_callable", [True, False])

pandas/tests/extension/json/test_json.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -356,18 +356,25 @@ def test_setitem_integer_array(self, data, idx, box_in_series, request):
356356
request.applymarker(mark)
357357
super().test_setitem_integer_array(data, idx, box_in_series)
358358

359-
@pytest.mark.xfail(reason="list indices must be integers or slices, not NAType")
360359
@pytest.mark.parametrize(
361-
"idx, box_in_series",
360+
"idx",
361+
[
362+
[0, 1, 2, pd.NA],
363+
pd.array([0, 1, 2, pd.NA], dtype="Int64"),
364+
],
365+
ids=["list", "integer-array"],
366+
)
367+
@pytest.mark.parametrize(
368+
"box_in_series",
362369
[
363-
([0, 1, 2, pd.NA], False),
370+
True,
364371
pytest.param(
365-
[0, 1, 2, pd.NA], True, marks=pytest.mark.xfail(reason="GH-31948")
372+
False,
373+
marks=pytest.mark.xfail(
374+
reason="list indices must be integers or slices, not NAType"
375+
),
366376
),
367-
(pd.array([0, 1, 2, pd.NA], dtype="Int64"), False),
368-
(pd.array([0, 1, 2, pd.NA], dtype="Int64"), True),
369377
],
370-
ids=["list-False", "list-True", "integer-array-False", "integer-array-True"],
371378
)
372379
def test_setitem_integer_with_missing_raises(self, data, idx, box_in_series):
373380
super().test_setitem_integer_with_missing_raises(data, idx, box_in_series)

0 commit comments

Comments
 (0)