Skip to content

BUG/TST: PeriodArray.__setitem__ with slice and list-like value #23991

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Dec 2, 2018
18 changes: 18 additions & 0 deletions pandas/tests/arrays/test_period.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,21 @@ def test_sub_period():
other = pd.Period("2000", freq="M")
with pytest.raises(IncompatibleFrequency, match="freq"):
arr - other


@pytest.mark.parametrize('data', [
period_array(['2001', '2002', '2003', '2004', '2005'], freq="D")
])
def test_setitem_slice_mismatch_length_raises(data):
arr = data[:5]
with pytest.raises(ValueError):
arr[:1] = arr[:2]


@pytest.mark.parametrize('data', [
period_array(['2001', '2002', '2003', '2004', '2005'], freq="D")
])
def test_setitem_slice_array(data):
arr = data[:5].copy()
arr[:5] = data[-5:]
tm.assert_extension_array_equal(arr, data[-5:])